io.vertx.servicediscovery.Record.setType()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(81)

本文整理了Java中io.vertx.servicediscovery.Record.setType方法的一些代码示例,展示了Record.setType的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Record.setType方法的具体详情如下:
包路径:io.vertx.servicediscovery.Record
类名称:Record
方法名:setType

Record.setType介绍

[英]Sets the type of service.
[中]

代码示例

代码示例来源:origin: vert-x3/vertx-examples

.setType("eventbus-service-proxy")
.setLocation(new JsonObject().put("endpoint", "the-service-address"))
.setName("my-service")

代码示例来源:origin: sczyh30/vertx-blueprint-microservice

protected Future<Void> publishApiGateway(String host, int port) {
 Record record = HttpEndpoint.createRecord("api-gateway", true, host, port, "/", null)
  .setType("api-gateway");
 return publish(record);
}

代码示例来源:origin: silentbalanceyh/vertx-zero

@Override
public ConcurrentMap<String, Record> getRegistryData() {
  final ConcurrentMap<String, Record> map = this.readData(EtcdPath.IPC);
  for (final Record record : map.values()) {
    record.setStatus(Status.UP);
    record.setType("IPC");
    // Alpn Enabled for Rpc, ssl must be true.
    record.getLocation().put("ssl", Boolean.TRUE);
  }
  return map;
}

代码示例来源:origin: cn.vertxup/vertx-up

@Override
public ConcurrentMap<String, Record> getRegistryData() {
  final ConcurrentMap<String, Record> map = this.readData(EtcdPath.IPC);
  for (final Record record : map.values()) {
    record.setStatus(Status.UP);
    record.setType("IPC");
    // Alpn Enabled for Rpc, ssl must be true.
    record.getLocation().put("ssl", Boolean.TRUE);
  }
  return map;
}

代码示例来源:origin: vert-x3/vertx-service-discovery

private Record manageUnknownService(Record record, ContainerPort port) {
 if (port.getPublicPort() == null || port.getPublicPort() == 0) {
  return null;
 }
 JsonObject location = new JsonObject();
 location.put("port", port.getPublicPort());
 location.put("internal-port", port.getPrivatePort());
 location.put("type", port.getType());
 location.put("ip", host);
 return record.setLocation(location).setType(ServiceType.UNKNOWN);
}

代码示例来源:origin: io.vertx/vertx-service-discovery

static Record createRecord(String name, JsonObject location, JsonObject metadata) {
 Objects.requireNonNull(name);
 Objects.requireNonNull(location);
 Record record = new Record().setName(name)
   .setType(TYPE)
   .setLocation(location);
 if (metadata != null) {
  record.setMetadata(metadata);
 }
 return record;
}

代码示例来源:origin: vert-x3/vertx-service-discovery

static Record createRecord(String name, JsonObject location, JsonObject metadata) {
 Objects.requireNonNull(name);
 Objects.requireNonNull(location);
 Record record = new Record().setName(name)
   .setType(TYPE)
   .setLocation(location);
 if (metadata != null) {
  record.setMetadata(metadata);
 }
 return record;
}

代码示例来源:origin: io.vertx/vertx-service-discovery

/**
 * Convenient method to create a record for a Redis data source.
 *
 * @param name     the service name
 * @param location the location of the service (e.g. url, port...)
 * @param metadata additional metadata
 * @return the created record
 */
static Record createRecord(String name, JsonObject location, JsonObject metadata) {
 Objects.requireNonNull(name);
 Objects.requireNonNull(location);
 Record record = new Record().setName(name)
  .setType(TYPE)
  .setLocation(location);
 if (metadata != null) {
  record.setMetadata(metadata);
 }
 return record;
}

代码示例来源:origin: vert-x3/vertx-service-discovery

/**
 * Convenient method to create a record for a Redis data source.
 *
 * @param name     the service name
 * @param location the location of the service (e.g. url, port...)
 * @param metadata additional metadata
 * @return the created record
 */
static Record createRecord(String name, JsonObject location, JsonObject metadata) {
 Objects.requireNonNull(name);
 Objects.requireNonNull(location);
 Record record = new Record().setName(name)
  .setType(TYPE)
  .setLocation(location);
 if (metadata != null) {
  record.setMetadata(metadata);
 }
 return record;
}

代码示例来源:origin: io.vertx/vertx-service-discovery

/**
 * Convenient method to create a record for a Mongo data source.
 *
 * @param name     the service name
 * @param location the location of the service (e.g. url, port...)
 * @param metadata additional metadata
 * @return the created record
 */
static Record createRecord(String name, JsonObject location, JsonObject metadata) {
 Objects.requireNonNull(name);
 Objects.requireNonNull(location);
 Record record = new Record().setName(name)
  .setType(TYPE)
  .setLocation(location);
 if (metadata != null) {
  record.setMetadata(metadata);
 }
 return record;
}

代码示例来源:origin: io.vertx/vertx-service-discovery

@Test
public void TestTypeMatch() {
 Record record = new Record().setName("Name").setType(HttpEndpoint.TYPE);
 assertThat(record.match(new JsonObject().put("name", "Name").put("type", "any"))).isFalse();
 assertThat(record.match(new JsonObject().put("name", "Name").put("type", HttpEndpoint.TYPE))).isTrue();
 assertThat(record.match(new JsonObject().put("type", HttpEndpoint.TYPE))).isTrue();
 assertThat(record.match(new JsonObject().put("name", "Name").put("type", "*"))).isTrue();
}

代码示例来源:origin: vert-x3/vertx-service-discovery

@Test
public void TestTypeMatch() {
 Record record = new Record().setName("Name").setType(HttpEndpoint.TYPE);
 assertThat(record.match(new JsonObject().put("name", "Name").put("type", "any"))).isFalse();
 assertThat(record.match(new JsonObject().put("name", "Name").put("type", HttpEndpoint.TYPE))).isTrue();
 assertThat(record.match(new JsonObject().put("type", HttpEndpoint.TYPE))).isTrue();
 assertThat(record.match(new JsonObject().put("name", "Name").put("type", "*"))).isTrue();
}

代码示例来源:origin: vert-x3/vertx-service-discovery

@Test(expected = IllegalArgumentException.class)
public void unknown() {
 Record record = new Record();
 record.setType(ServiceType.UNKNOWN);
 ServiceTypes.get(record);
}

代码示例来源:origin: io.vertx/vertx-service-discovery

@Test(expected = IllegalArgumentException.class)
public void unknown() {
 Record record = new Record();
 record.setType(ServiceType.UNKNOWN);
 ServiceTypes.get(record);
}

代码示例来源:origin: io.vertx/vertx-service-discovery

@Test(expected = IllegalArgumentException.class)
public void notAKnownType() {
 Record record = new Record();
 record.setType("bob");
 ServiceTypes.get(record);
}

代码示例来源:origin: vert-x3/vertx-service-discovery

@Test(expected = IllegalArgumentException.class)
public void notAKnownType() {
 Record record = new Record();
 record.setType("bob");
 ServiceTypes.get(record);
}

代码示例来源:origin: engagingspaces/vertx-graphql-service-discovery

@Test
public void should_Fail_Service_Proxy_With_Record_Status_Not_UP(TestContext context) {
  GraphQLClient.getSchemaProxy(discovery, new Record()
      .setName("DroidQueries").setType(Queryable.SERVICE_TYPE),
          context.asyncAssertFailure(ex ->
            assertEquals("Record status indicates service 'DroidQueries' is: UNKNOWN. Expected: UP",
                ex.getMessage())
          ));
}

代码示例来源:origin: engagingspaces/vertx-graphql-service-discovery

@Before
public void setUp() {
  vertx = Vertx.vertx();
  options = new ServiceDiscoveryOptions().setName("theDiscovery")
      .setAnnounceAddress("theAnnounceAddress").setUsageAddress("theUsageAddress");
  discovery = ServiceDiscovery.create(vertx, options);
  record = new Record()
      .setName("theRecord")
      .setType(Queryable.SERVICE_TYPE)
      .setMetadata(new JsonObject().put("publisherId", "thePublisherId"))
      .setLocation(new JsonObject().put(Record.ENDPOINT, Queryable.ADDRESS_PREFIX + ".DroidQueries"))
      .setStatus(Status.UP);
  definition = SchemaDefinition.createInstance(droidsSchema,
      SchemaMetadata.create(new JsonObject().put("publisherId", "thePublisherId")));
  consumer = ProxyHelper.registerService(Queryable.class,
      vertx, definition, Queryable.ADDRESS_PREFIX + ".DroidQueries");
}

代码示例来源:origin: engagingspaces/vertx-graphql-service-discovery

@Test
  public void should_Fail_Service_Proxy_With_Record_Not_Registered(TestContext context) {
    GraphQLClient.getSchemaProxy(discovery, new Record()
        .setName("DroidQueries").setType(Queryable.SERVICE_TYPE).setStatus(Status.UP),
            context.asyncAssertFailure(ex ->
              assertEquals("Record 'DroidQueries' has no service discovery registration", ex.getMessage())
            ));
  }
}

代码示例来源:origin: vert-x3/vertx-service-discovery

private static Record manageHttpService(Record record, ContainerPort port, Map<String, String> labels) {
 if (port.getPublicPort() == null || port.getPublicPort() == 0) {
  return null;
 }
 record.setType(HttpEndpoint.TYPE);
 HttpLocation location = new HttpLocation()
   .setHost(port.getIp())
   .setPort(port.getPublicPort());
 if (isTrue(labels, "ssl")  || port.getPrivatePort() == 443) {
  location.setSsl(true);
 }
 return record.setLocation(location.toJson());
}

相关文章