Package io.grpc
Class LoadBalancerRegistry
java.lang.Object
io.grpc.LoadBalancerRegistry
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1771")
@ThreadSafe
public final class LoadBalancerRegistry
extends Object
Registry of
LoadBalancerProvider
s. The default instance
loads providers at runtime through the Java service provider mechanism.- Since:
- 1.17.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
deregister
(LoadBalancerProvider provider) Deregisters a provider.static LoadBalancerRegistry
Returns the default registry that loads providers via the Java service loader mechanism.getProvider
(String policy) Returns the effective provider for the given load-balancing policy, ornull
if no suitable provider can be found.void
register
(LoadBalancerProvider provider) Register a provider.
-
Constructor Details
-
LoadBalancerRegistry
public LoadBalancerRegistry()
-
-
Method Details
-
register
Register a provider.If the provider's
isAvailable()
returnsfalse
, this method will throwIllegalArgumentException
.If more than one provider with the same
policy name
are registered, the one with the highestpriority
will be effective. If there are more than one name-sake providers rank the highest priority, the one registered first will be effective. -
deregister
Deregisters a provider. No-op if the provider is not in the registry. If there are more than one providers with the same policy name as the deregistered one in the registry, one of them will become the effective provider for that policy, per the rule documented inregister(io.grpc.LoadBalancerProvider)
.- Parameters:
provider
- the provider that was added to the register viaregister(io.grpc.LoadBalancerProvider)
.
-
getDefaultRegistry
Returns the default registry that loads providers via the Java service loader mechanism. -
getProvider
Returns the effective provider for the given load-balancing policy, ornull
if no suitable provider can be found. Each provider declares its policy name viaLoadBalancerProvider.getPolicyName()
.
-