Package io.grpc.internal
Class ServiceConfigState
- java.lang.Object
-
- io.grpc.internal.ServiceConfigState
-
final class ServiceConfigState extends java.lang.Object
ServiceConfigState
holds the state of the current service config. It must be mutated and read fromManagedChannelImpl
constructor or the provided syncContext.
-
-
Field Summary
Fields Modifier and Type Field Description private NameResolver.ConfigOrError
currentServiceConfigOrError
private NameResolver.ConfigOrError
defaultServiceConfig
private boolean
lookUpServiceConfig
private boolean
updated
-
Constructor Summary
Constructors Constructor Description ServiceConfigState(ManagedChannelServiceConfig defaultServiceConfig, boolean lookUpServiceConfig)
Construct new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) boolean
expectUpdates()
(package private) NameResolver.ConfigOrError
getCurrent()
Gets the current service config or error.(package private) boolean
shouldWaitOnServiceConfig()
Returnstrue
if it RPCs should wait on a service config resolution.(package private) void
update(NameResolver.ConfigOrError coe)
-
-
-
Field Detail
-
defaultServiceConfig
@Nullable private final NameResolver.ConfigOrError defaultServiceConfig
-
lookUpServiceConfig
private final boolean lookUpServiceConfig
-
currentServiceConfigOrError
@Nullable private NameResolver.ConfigOrError currentServiceConfigOrError
-
updated
private boolean updated
-
-
Constructor Detail
-
ServiceConfigState
ServiceConfigState(@Nullable ManagedChannelServiceConfig defaultServiceConfig, boolean lookUpServiceConfig)
Construct new instance.- Parameters:
defaultServiceConfig
- The initial service config, ornull
if absent.lookUpServiceConfig
-true
if service config updates might occur.
-
-
Method Detail
-
shouldWaitOnServiceConfig
boolean shouldWaitOnServiceConfig()
Returnstrue
if it RPCs should wait on a service config resolution. This can returnfalse
if:- There is a valid service config from the name resolver
- There is a valid default service config and a service config error from the name resolver
- No service config from the name resolver, and no intent to lookup a service config.
In the final case, the default service config may be present or absent, and will be the current service config.
-
getCurrent
@Nullable NameResolver.ConfigOrError getCurrent()
Gets the current service config or error.- Throws:
java.lang.IllegalStateException
- if the service config has not yet been updated.
-
update
void update(@Nullable NameResolver.ConfigOrError coe)
-
expectUpdates
boolean expectUpdates()
-
-