@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1770") @ThreadSafe public abstract class NameResolver extends Object
URI
and return addresses to the caller.
A NameResolver
uses the URI's scheme to determine whether it can resolve it, and uses
the components after the scheme for actual resolution.
The addresses and attributes of a target may be changed over time, thus the caller registers a
NameResolver.Listener
to receive continuous updates.
Modifier and Type | Class and Description |
---|---|
static class |
NameResolver.Factory |
static interface |
NameResolver.Listener
Receives address updates.
|
Constructor and Description |
---|
NameResolver() |
Modifier and Type | Method and Description |
---|---|
abstract String |
getServiceAuthority()
Returns the authority used to authenticate connections to servers.
|
void |
refresh()
Re-resolve the name.
|
abstract void |
shutdown()
Stops the resolution.
|
abstract void |
start(NameResolver.Listener listener)
Starts the resolution.
|
public abstract String getServiceAuthority()
An implementation must generate it without blocking, typically in line, and
must keep it unchanged. NameResolver
s created from the same factory
with the same argument must return the same authority.
public abstract void start(NameResolver.Listener listener)
listener
- used to receive updates on the targetpublic abstract void shutdown()
public void refresh()
Can only be called after start(io.grpc.NameResolver.Listener)
has been called.
This is only a hint. Implementation takes it as a signal but may not start resolution immediately. It should never throw.
The default implementation is no-op.