public class DiscoveryClientResolverFactory
extends io.grpc.NameResolverProvider
DiscoveryClientNameResolver based on the target uri.| Modifier and Type | Field and Description |
|---|---|
static io.grpc.Attributes.Key<String> |
DISCOVERY_INSTANCE_ID_KEY
A key for the
instance id. |
static String |
DISCOVERY_SCHEME
The constant containing the scheme that will be used by this factory.
|
static io.grpc.Attributes.Key<String> |
DISCOVERY_SERVICE_NAME_KEY
A key for the service name used to related
ServiceInstances from the DiscoveryClient. |
| Constructor and Description |
|---|
DiscoveryClientResolverFactory(org.springframework.cloud.client.discovery.DiscoveryClient client)
Creates a new discovery client based name resolver factory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Cleans up the name resolvers.
|
String |
getDefaultScheme() |
void |
heartbeat(org.springframework.cloud.client.discovery.event.HeartbeatEvent event)
Triggers a refresh of the registered name resolvers.
|
protected boolean |
isAvailable() |
protected DiscoveryClientNameResolver |
newNameResolver(String serviceName,
io.grpc.NameResolver.Args args)
Factory method to create the resolver for the given service name.
|
io.grpc.NameResolver |
newNameResolver(URI targetUri,
io.grpc.NameResolver.Args args) |
protected int |
priority() |
String |
toString() |
public static final String DISCOVERY_SCHEME
public static final io.grpc.Attributes.Key<String> DISCOVERY_SERVICE_NAME_KEY
ServiceInstances from the DiscoveryClient.public static final io.grpc.Attributes.Key<String> DISCOVERY_INSTANCE_ID_KEY
instance id.public DiscoveryClientResolverFactory(org.springframework.cloud.client.discovery.DiscoveryClient client)
client - The client to use for the address discovery.@Nullable public io.grpc.NameResolver newNameResolver(URI targetUri, io.grpc.NameResolver.Args args)
newNameResolver in class io.grpc.NameResolver.Factoryprotected DiscoveryClientNameResolver newNameResolver(String serviceName, io.grpc.NameResolver.Args args)
serviceName - The service name to create it for.args - The NameResolver arguments to use.public String getDefaultScheme()
getDefaultScheme in class io.grpc.NameResolver.Factoryprotected boolean isAvailable()
isAvailable in class io.grpc.NameResolverProviderprotected int priority()
priority in class io.grpc.NameResolverProvider@EventListener(value=org.springframework.cloud.client.discovery.event.HeartbeatEvent.class) public void heartbeat(org.springframework.cloud.client.discovery.event.HeartbeatEvent event)
event - The event that triggered the update.@PreDestroy public void destroy()