Class ServiceConfigUtil

java.lang.Object
io.grpc.internal.ServiceConfigUtil

public final class ServiceConfigUtil extends Object
Helper utility to work with service configs.

This class contains helper methods to parse service config JSON values into Java types.

  • 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. null if 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. null if can't find one.
    • getThrottlePolicy

      @Nullable static RetriableStream.Throttle getThrottlePolicy(@Nullable Map<String,?> serviceConfig)
    • getMaxAttemptsFromRetryPolicy

      @Nullable static Integer getMaxAttemptsFromRetryPolicy(Map<String,?> retryPolicy)
    • getInitialBackoffNanosFromRetryPolicy

      @Nullable static Long getInitialBackoffNanosFromRetryPolicy(Map<String,?> retryPolicy)
    • getMaxBackoffNanosFromRetryPolicy

      @Nullable static Long getMaxBackoffNanosFromRetryPolicy(Map<String,?> retryPolicy)
    • getBackoffMultiplierFromRetryPolicy

      @Nullable static Double getBackoffMultiplierFromRetryPolicy(Map<String,?> retryPolicy)
    • getPerAttemptRecvTimeoutNanosFromRetryPolicy

      @Nullable static Long getPerAttemptRecvTimeoutNanosFromRetryPolicy(Map<String,?> retryPolicy)
    • getListOfStatusCodesAsSet

      private static Set<Status.Code> getListOfStatusCodesAsSet(Map<String,?> obj, String key)
    • getStatusCodesFromList

      private static Set<Status.Code> getStatusCodesFromList(List<?> statuses)
    • getRetryableStatusCodesFromRetryPolicy

      static Set<Status.Code> getRetryableStatusCodesFromRetryPolicy(Map<String,?> retryPolicy)
    • getMaxAttemptsFromHedgingPolicy

      @Nullable static Integer getMaxAttemptsFromHedgingPolicy(Map<String,?> hedgingPolicy)
    • getHedgingDelayNanosFromHedgingPolicy

      @Nullable static Long getHedgingDelayNanosFromHedgingPolicy(Map<String,?> hedgingPolicy)
    • getNonFatalStatusCodesFromHedgingPolicy

      static Set<Status.Code> getNonFatalStatusCodesFromHedgingPolicy(Map<String,?> hedgingPolicy)
    • getServiceFromName

      @Nullable static String getServiceFromName(Map<String,?> name)
    • getMethodFromName

      @Nullable static String getMethodFromName(Map<String,?> name)
    • getRetryPolicyFromMethodConfig

      @Nullable static Map<String,?> getRetryPolicyFromMethodConfig(Map<String,?> methodConfig)
    • getHedgingPolicyFromMethodConfig

      @Nullable static Map<String,?> getHedgingPolicyFromMethodConfig(Map<String,?> methodConfig)
    • getNameListFromMethodConfig

      @Nullable static List<Map<String,?>> getNameListFromMethodConfig(Map<String,?> methodConfig)
    • getTimeoutFromMethodConfig

      @Nullable static Long getTimeoutFromMethodConfig(Map<String,?> methodConfig)
      Returns the number of nanoseconds of timeout for the given method config.
      Returns:
      duration nanoseconds, or null if it isn't present.
    • getWaitForReadyFromMethodConfig

      @Nullable static Boolean getWaitForReadyFromMethodConfig(Map<String,?> methodConfig)
    • getMaxRequestMessageBytesFromMethodConfig

      @Nullable static Integer getMaxRequestMessageBytesFromMethodConfig(Map<String,?> methodConfig)
    • getMaxResponseMessageBytesFromMethodConfig

      @Nullable static Integer getMaxResponseMessageBytesFromMethodConfig(Map<String,?> methodConfig)
    • getMethodConfigFromServiceConfig

      @Nullable static List<Map<String,?>> getMethodConfigFromServiceConfig(Map<String,?> serviceConfig)
    • getLoadBalancingConfigsFromServiceConfig

      public static List<Map<String,?>> getLoadBalancingConfigsFromServiceConfig(Map<String,?> serviceConfig)
      Extracts load balancing configs from a service config.
    • unwrapLoadBalancingConfig

      public static ServiceConfigUtil.LbConfig unwrapLoadBalancingConfig(Map<String,?> lbConfig)
      Unwrap a LoadBalancingConfig JSON object into a ServiceConfigUtil.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 a ServiceConfigUtil.PolicySelection as its config value.