Package io.grpc.internal
Class ServiceConfigUtil
java.lang.Object
io.grpc.internal.ServiceConfigUtil
Helper utility to work with service configs.
This class contains helper methods to parse service config JSON values into Java types.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA LoadBalancingConfig that includes the policy name (the key) and its raw config value (parsed JSON).static final class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static DoublegetBackoffMultiplierFromRetryPolicy(Map<String, ?> retryPolicy) getHealthCheckedService(Map<String, ?> serviceConfig) Fetches the health-checked service config from service config.static StringgetHealthCheckedServiceName(Map<String, ?> healthCheckedServiceConfig) Fetches the health-checked service name from health-checked service config.(package private) static LonggetHedgingDelayNanosFromHedgingPolicy(Map<String, ?> hedgingPolicy) getHedgingPolicyFromMethodConfig(Map<String, ?> methodConfig) (package private) static LonggetInitialBackoffNanosFromRetryPolicy(Map<String, ?> retryPolicy) private static Set<Status.Code> getListOfStatusCodesAsSet(Map<String, ?> obj, String key) getLoadBalancingConfigsFromServiceConfig(Map<String, ?> serviceConfig) Extracts load balancing configs from a service config.(package private) static IntegergetMaxAttemptsFromHedgingPolicy(Map<String, ?> hedgingPolicy) (package private) static IntegergetMaxAttemptsFromRetryPolicy(Map<String, ?> retryPolicy) (package private) static LonggetMaxBackoffNanosFromRetryPolicy(Map<String, ?> retryPolicy) (package private) static IntegergetMaxRequestMessageBytesFromMethodConfig(Map<String, ?> methodConfig) (package private) static IntegergetMaxResponseMessageBytesFromMethodConfig(Map<String, ?> methodConfig) getMethodConfigFromServiceConfig(Map<String, ?> serviceConfig) (package private) static StringgetMethodFromName(Map<String, ?> name) getNameListFromMethodConfig(Map<String, ?> methodConfig) (package private) static Set<Status.Code> getNonFatalStatusCodesFromHedgingPolicy(Map<String, ?> hedgingPolicy) (package private) static LonggetPerAttemptRecvTimeoutNanosFromRetryPolicy(Map<String, ?> retryPolicy) (package private) static Set<Status.Code> getRetryableStatusCodesFromRetryPolicy(Map<String, ?> retryPolicy) getRetryPolicyFromMethodConfig(Map<String, ?> methodConfig) (package private) static StringgetServiceFromName(Map<String, ?> name) private static Set<Status.Code> getStatusCodesFromList(List<?> statuses) (package private) static RetriableStream.ThrottlegetThrottlePolicy(Map<String, ?> serviceConfig) (package private) static LonggetTimeoutFromMethodConfig(Map<String, ?> methodConfig) Returns the number of nanoseconds of timeout for the given method config.(package private) static BooleangetWaitForReadyFromMethodConfig(Map<String, ?> methodConfig) static NameResolver.ConfigOrErrorselectLbPolicyFromList(List<ServiceConfigUtil.LbConfig> lbConfigs, LoadBalancerRegistry lbRegistry) Parses and selects a load balancing policy from a non-empty list of raw configs.static ServiceConfigUtil.LbConfigunwrapLoadBalancingConfig(Map<String, ?> lbConfig) Unwrap a LoadBalancingConfig JSON object into aServiceConfigUtil.LbConfig.static List<ServiceConfigUtil.LbConfig> unwrapLoadBalancingConfigList(List<Map<String, ?>> list) Given a JSON list of LoadBalancingConfigs, and convert it into a list of LbConfig.
-
Constructor Details
-
ServiceConfigUtil
private ServiceConfigUtil()
-
-
Method Details
-
getHealthCheckedService
@Nullable public static Map<String,?> getHealthCheckedService(@Nullable Map<String, ?> serviceConfig) Fetches the health-checked service config from service config.nullif can't find one. -
getHealthCheckedServiceName
@Nullable public static String getHealthCheckedServiceName(@Nullable Map<String, ?> healthCheckedServiceConfig) Fetches the health-checked service name from health-checked service config.nullif can't find one. -
getThrottlePolicy
-
getMaxAttemptsFromRetryPolicy
-
getInitialBackoffNanosFromRetryPolicy
-
getMaxBackoffNanosFromRetryPolicy
-
getBackoffMultiplierFromRetryPolicy
-
getPerAttemptRecvTimeoutNanosFromRetryPolicy
-
getListOfStatusCodesAsSet
-
getStatusCodesFromList
-
getRetryableStatusCodesFromRetryPolicy
-
getMaxAttemptsFromHedgingPolicy
-
getHedgingDelayNanosFromHedgingPolicy
-
getNonFatalStatusCodesFromHedgingPolicy
-
getServiceFromName
-
getMethodFromName
-
getRetryPolicyFromMethodConfig
-
getHedgingPolicyFromMethodConfig
-
getNameListFromMethodConfig
-
getTimeoutFromMethodConfig
Returns the number of nanoseconds of timeout for the given method config.- Returns:
- duration nanoseconds, or
nullif it isn't present.
-
getWaitForReadyFromMethodConfig
-
getMaxRequestMessageBytesFromMethodConfig
-
getMaxResponseMessageBytesFromMethodConfig
-
getMethodConfigFromServiceConfig
-
getLoadBalancingConfigsFromServiceConfig
public static List<Map<String,?>> getLoadBalancingConfigsFromServiceConfig(Map<String, ?> serviceConfig) Extracts load balancing configs from a service config. -
unwrapLoadBalancingConfig
Unwrap a LoadBalancingConfig JSON object into aServiceConfigUtil.LbConfig. The input is a JSON object (map) with exactly one entry, where the key is the policy name and the value is a config object for that policy. -
unwrapLoadBalancingConfigList
public static List<ServiceConfigUtil.LbConfig> unwrapLoadBalancingConfigList(List<Map<String, ?>> list) Given a JSON list of LoadBalancingConfigs, and convert it into a list of LbConfig. -
selectLbPolicyFromList
public static NameResolver.ConfigOrError selectLbPolicyFromList(List<ServiceConfigUtil.LbConfig> lbConfigs, LoadBalancerRegistry lbRegistry) Parses and selects a load balancing policy from a non-empty list of raw configs. If selection is successful, the returned ConfigOrError object will include aServiceConfigUtil.PolicySelectionas its config value.
-