当前位置: 首页>>代码示例>>Java>>正文


Java GrpcUtil.TIMER_SERVICE属性代码示例

本文整理汇总了Java中io.grpc.internal.GrpcUtil.TIMER_SERVICE属性的典型用法代码示例。如果您正苦于以下问题:Java GrpcUtil.TIMER_SERVICE属性的具体用法?Java GrpcUtil.TIMER_SERVICE怎么用?Java GrpcUtil.TIMER_SERVICE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在io.grpc.internal.GrpcUtil的用法示例。


在下文中一共展示了GrpcUtil.TIMER_SERVICE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newNameResolver

@Nullable
@Override
public NameResolver newNameResolver(URI targetUri, Attributes params) {
  if (SCHEME.equals(targetUri.getScheme())) {
    String targetPath = Preconditions.checkNotNull(targetUri.getPath(), "targetPath");
    Preconditions.checkArgument(targetPath.startsWith("/"),
        "the path component (%s) of the target (%s) must start with '/'", targetPath, targetUri);

    String[] parts = targetPath.split("/");
    if (parts.length != 4) {
      throw new IllegalArgumentException("Must be formatted like kubernetes:///{namespace}/{service}/{port}");
    }

    try {
      int port = Integer.valueOf(parts[3]);
      return new KubernetesNameResolver(parts[1], parts[2], port, params, GrpcUtil.TIMER_SERVICE,
          GrpcUtil.SHARED_CHANNEL_EXECUTOR);
    } catch (NumberFormatException e) {
      throw new IllegalArgumentException("Unable to parse port number", e);
    }
  } else {
    return null;
  }
}
 
开发者ID:saturnism,项目名称:grpc-java-by-example,代码行数:24,代码来源:KubernetesNameResolverProvider.java

示例2: newNameResolver

@Nullable
@Override
public ConsulNameResolver newNameResolver(final URI targetUri, final Attributes params) {
    if (!SCHEME.equals(targetUri.getScheme())) {
        return null;
    }

    final String targetPath = checkNotNull(targetUri.getPath(), "targetPath");
    checkArgument(targetPath.startsWith("/"));

    final String serviceName = targetPath.substring(1);
    checkArgument(serviceName.length() > 0, "serviceName");

    String consulHost = targetUri.getHost();
    if (Strings.isNullOrEmpty(consulHost)) {
        consulHost = DEFAULT_HOST;
    }

    int consulPort = targetUri.getPort();
    if (consulPort == -1) {
        consulPort = DEFAULT_PORT;
    }

    final String tag = Strings.emptyToNull(targetUri.getFragment());

    final ConsulClient consulClient = ConsulClientManager.getInstance(consulHost, consulPort);

    return new ConsulNameResolver(
            consulClient /* CatalogClient */,
            consulClient /* KeyValueClient */,
            serviceName,
            Optional.ofNullable(tag),
            GrpcUtil.TIMER_SERVICE,
            GrpcUtil.SHARED_CHANNEL_EXECUTOR
    );
}
 
开发者ID:indeedeng-alpha,项目名称:indeed-grpc-java,代码行数:36,代码来源:ConsulNameResolverProvider.java

示例3: setup

@Before
public void setup() {
    resolver = new ConsulNameResolver(
            catalogClient,
            keyValueClient,
            SERVICE_NAME,
            Optional.empty(),
            GrpcUtil.TIMER_SERVICE,
            GrpcUtil.SHARED_CHANNEL_EXECUTOR,
            1, TimeUnit.SECONDS
    );
}
 
开发者ID:indeedeng-alpha,项目名称:indeed-grpc-java,代码行数:12,代码来源:ConsulNameResolverTest.java

示例4: getPort_notStarted

@Test
public void getPort_notStarted() throws Exception {
  InProcessServer s =
      new InProcessServer("name", GrpcUtil.TIMER_SERVICE,
          Collections.<ServerStreamTracer.Factory>emptyList());

  Truth.assertThat(s.getPort()).isEqualTo(-1);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:8,代码来源:InProcessServerTest.java

示例5: buildTransportServer

@Override
protected InProcessServer buildTransportServer(
    List<ServerStreamTracer.Factory> streamTracerFactories) {
  return new InProcessServer(name, GrpcUtil.TIMER_SERVICE, streamTracerFactories);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:5,代码来源:InProcessServerBuilder.java

示例6: newServer

@Override
protected InternalServer newServer(List<ServerStreamTracer.Factory> streamTracerFactories) {
  return new InProcessServer(TRANSPORT_NAME, GrpcUtil.TIMER_SERVICE, streamTracerFactories);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:4,代码来源:InProcessTransportTest.java


注:本文中的io.grpc.internal.GrpcUtil.TIMER_SERVICE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。