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
ServiceInstance s 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
ServiceInstance
s 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.Factory
protected 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.Factory
protected boolean isAvailable()
isAvailable
in class io.grpc.NameResolverProvider
protected 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()