下面列出了io.grpc.internal.SharedResourceHolder#Resource ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Creates a self name resolver with the given properties.
*
* @param properties The properties to read the server address from.
* @param args The arguments for the resolver.
* @param executorResource The shared executor resource for channels.
*/
public SelfNameResolver(final GrpcServerProperties properties, final Args args,
final SharedResourceHolder.Resource<Executor> executorResource) {
this.properties = requireNonNull(properties, "properties");
this.syncContext = requireNonNull(args.getSynchronizationContext(), "syncContext");
this.executorResource = requireNonNull(executorResource, "executorResource");
this.executor = args.getOffloadExecutor();
this.usingExecutorResource = this.executor == null;
}
/**
* Creates a new DiscoveryClientNameResolver.
*
* @param name The name of the service to look up.
* @param client The client used to look up the service addresses.
* @param args The name resolver args.
* @param executorResource The executor resource.
* @param externalCleaner The optional cleaner used during {@link #shutdown()}
*/
public DiscoveryClientNameResolver(final String name, final DiscoveryClient client, final Args args,
final SharedResourceHolder.Resource<Executor> executorResource, final Runnable externalCleaner) {
this.name = name;
this.client = client;
this.syncContext = requireNonNull(args.getSynchronizationContext(), "syncContext");
this.externalCleaner = externalCleaner;
this.executor = args.getOffloadExecutor();
this.usingExecutorResource = this.executor == null;
this.executorResource = executorResource;
}
/**
* Creates a self name resolver with the given properties.
*
* @param properties The properties to read the server address from.
* @param args The arguments for the resolver.
* @param executorResource The shared executor resource for channels.
*/
public SelfNameResolver(final GrpcServerProperties properties, final Args args,
final SharedResourceHolder.Resource<Executor> executorResource) {
this.properties = requireNonNull(properties, "properties");
this.syncContext = requireNonNull(args.getSynchronizationContext(), "syncContext");
this.executorResource = requireNonNull(executorResource, "executorResource");
this.executor = args.getOffloadExecutor();
this.usingExecutorResource = this.executor == null;
}
/**
* Creates a new DiscoveryClientNameResolver.
*
* @param name The name of the service to look up.
* @param client The client used to look up the service addresses.
* @param args The name resolver args.
* @param executorResource The executor resource.
* @param externalCleaner The optional cleaner used during {@link #shutdown()}
*/
public DiscoveryClientNameResolver(final String name, final DiscoveryClient client, final Args args,
final SharedResourceHolder.Resource<Executor> executorResource, final Runnable externalCleaner) {
this.name = name;
this.client = client;
this.syncContext = requireNonNull(args.getSynchronizationContext(), "syncContext");
this.externalCleaner = externalCleaner;
this.executor = args.getOffloadExecutor();
this.usingExecutorResource = this.executor == null;
this.executorResource = executorResource;
}
public KubernetesNameResolver(String namespace, String name, int port, Attributes params, SharedResourceHolder.Resource<ScheduledExecutorService> timerServiceResource, SharedResourceHolder.Resource<Executor> sharedChannelExecutorResource) {
this.namespace = namespace;
this.name = name;
this.port = port;
this.params = params;
this.timerServiceResource = timerServiceResource;
this.sharedChannelExecutorResource = sharedChannelExecutorResource;
this.kubernetesClient = new DefaultKubernetesClient();
}