public class DiscoveryClientNameResolver extends NameResolver
DiscoveryClient. The ports are extracted from the gRPC_port metadata.NameResolver.Args, NameResolver.ConfigOrError, NameResolver.Factory, NameResolver.Listener, NameResolver.Listener2, NameResolver.ResolutionResult, NameResolver.ResolutionResultAttr, NameResolver.ServiceConfigParser| Constructor and Description |
|---|
DiscoveryClientNameResolver(String name,
DiscoveryClient client,
NameResolver.Args args,
io.grpc.internal.SharedResourceHolder.Resource<Executor> executorResource,
Consumer<DiscoveryClientNameResolver> shutdownHook)
Creates a new DiscoveryClientNameResolver.
|
| Modifier and Type | Method and Description |
|---|---|
protected List<ServiceInstance> |
discoverServers()
Discovers matching service instances.
|
protected Attributes |
getAttributes(ServiceInstance serviceInstance)
Gets the attributes from the service instance for later use in a load balancer.
|
protected int |
getGrpcPort(ServiceInstance instance)
Extracts the gRPC server port from the given service instance.
|
protected String |
getName()
Gets the name of the service to get the instances of.
|
String |
getServiceAuthority() |
protected boolean |
isActive()
Checks whether this resolver is active.
|
protected boolean |
needsToUpdateConnections(List<ServiceInstance> newInstanceList)
Checks whether this instance should update its connections.
|
void |
refresh() |
void |
refreshFromExternal()
Triggers a refresh on the listener from non-grpc threads.
|
void |
shutdown() |
void |
start(NameResolver.Listener2 listener) |
String |
toString() |
startpublic DiscoveryClientNameResolver(String name, DiscoveryClient client, NameResolver.Args args, io.grpc.internal.SharedResourceHolder.Resource<Executor> executorResource, Consumer<DiscoveryClientNameResolver> shutdownHook)
name - The name of the service to look up.client - The client used to look up the service addresses.args - The name resolver args.executorResource - The executor resource.shutdownHook - The optional cleaner used during shutdown()protected final String getName()
protected final boolean isActive()
#start has been called, but not #shutdown().public final String getServiceAuthority()
getServiceAuthority in class NameResolverpublic void start(NameResolver.Listener2 listener)
start in class NameResolverpublic void refresh()
refresh in class NameResolverpublic void refreshFromExternal()
refresh()protected List<ServiceInstance> discoverServers()
protected int getGrpcPort(ServiceInstance instance)
instance - The instance to extract the port from.IllegalArgumentException - If the specified port definition couldn't be parsed.protected Attributes getAttributes(ServiceInstance serviceInstance)
serviceInstance - The service instance to get them from.protected boolean needsToUpdateConnections(List<ServiceInstance> newInstanceList)
newInstanceList - The new instances that should be compared to the stored ones.public void shutdown()
shutdown in class NameResolver