Class NameResolver.Args
- Enclosing class:
NameResolver
NameResolver.Factory
uses to create a NameResolver
.
Args applicable to all NameResolver
s are defined here using ordinary setters and
getters. This container can also hold externally-defined "custom" args that aren't so widely
useful or that would be inappropriate dependencies for this low level API. See getArg(io.grpc.NameResolver.Args.Key<T>)
for more.
Note this class overrides neither equals()
nor hashCode()
.
- Since:
- 1.21.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Builder forNameResolver.Args
.static final class
Identifies an externally-defined custom argument that can be stored inNameResolver.Args
. -
Method Summary
Modifier and TypeMethodDescription<T> T
getArg
(NameResolver.Args.Key<T> key) Returns the value of a custom arg named 'key', ornull
if it's not set.Returns theChannelLogger
for the Channel served by this NameResolver.int
The port number used in case the target or the underlying naming system doesn't provide a port number.Returns theMetricRecorder
that the channel uses to record metrics.Returns the Executor on which this resolver should execute long-running or I/O bound work.Returns the overrideAuthority from channelManagedChannelBuilder.overrideAuthority(java.lang.String)
.If the NameResolver wants to support proxy, it should inquire thisProxyDetector
.Returns aScheduledExecutorService
for scheduling delayed tasks.Returns theNameResolver.ServiceConfigParser
.Returns theSynchronizationContext
whereNameResolver.start(Listener2)
,NameResolver.shutdown()
andNameResolver.refresh()
are run from.static NameResolver.Args.Builder
Creates a new builder.Returns a builder with the same initial values as this object.toString()
-
Method Details
-
getDefaultPort
public int getDefaultPort()The port number used in case the target or the underlying naming system doesn't provide a port number.- Since:
- 1.21.0
-
getProxyDetector
If the NameResolver wants to support proxy, it should inquire thisProxyDetector
. See documentation onProxyDetector
about how proxies work in gRPC.- Since:
- 1.21.0
-
getSynchronizationContext
Returns theSynchronizationContext
whereNameResolver.start(Listener2)
,NameResolver.shutdown()
andNameResolver.refresh()
are run from.- Since:
- 1.21.0
-
getScheduledExecutorService
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/6454") public ScheduledExecutorService getScheduledExecutorService()Returns aScheduledExecutorService
for scheduling delayed tasks.This service is a shared resource and is only meant for quick tasks. DO NOT block or run time-consuming tasks.
The returned service doesn't support
shutdown()
andshutdownNow()
. They will throw if called.- Since:
- 1.26.0
-
getServiceConfigParser
Returns theNameResolver.ServiceConfigParser
.- Since:
- 1.21.0
-
getArg
Returns the value of a custom arg named 'key', ornull
if it's not set.While ordinary
NameResolver.Args
should be universally useful and meaningful, custom arguments can apply just to resolvers of a certain URI scheme, just to resolvers producing a particular type ofSocketAddress
, or even an individualNameResolver
subclass. Custom args are identified by an instance ofNameResolver.Args.Key
which should be a constant defined in a java package and class appropriate for the argument's scope.NameResolver.Args
are normally reserved for information in *support* of name resolution, not the name to be resolved itself. However, there are rare cases where all or part of the target name can't be represented by any standard URI scheme or can't be encoded as a String at all. Custom args, in contrast, can hold arbitrary Java types, making them a useful work around in these cases.Custom args can also be used simply to avoid adding inappropriate deps to the low level io.grpc package.
-
getChannelLogger
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/6438") public ChannelLogger getChannelLogger()Returns theChannelLogger
for the Channel served by this NameResolver.- Since:
- 1.26.0
-
getOffloadExecutor
Returns the Executor on which this resolver should execute long-running or I/O bound work. Null if no Executor was set.- Since:
- 1.25.0
-
getOverrideAuthority
@Nullable @ExperimentalApi("https://github.com/grpc/grpc-java/issues/9406") public String getOverrideAuthority()Returns the overrideAuthority from channelManagedChannelBuilder.overrideAuthority(java.lang.String)
. Overrides the host name for L7 HTTP virtual host matching. Almost all name resolvers should not use this.- Since:
- 1.49.0
-
getMetricRecorder
Returns theMetricRecorder
that the channel uses to record metrics. -
toString
-
toBuilder
Returns a builder with the same initial values as this object.- Since:
- 1.21.0
-
newBuilder
Creates a new builder.- Since:
- 1.21.0
-