public static function load(
        $serviceName,
        $clientConfig,
        $disableRetries = false
    ) {
        $serviceRetrySettings = [];

        $serviceConfig = $clientConfig['interfaces'][$serviceName];
        $retryCodes = $serviceConfig['retry_codes'];
        $retryParams = $serviceConfig['retry_params'];
        foreach ($serviceConfig['methods'] as $methodName => $methodConfig) {
            $timeoutMillis = $methodConfig['timeout_millis'];

            if (empty($methodConfig['retry_codes_name']) || empty($methodConfig['retry_params_name'])) {
                // Construct a RetrySettings object with retries disabled
                $retrySettings = self::constructDefault()->with([
                    'noRetriesRpcTimeoutMillis' => $timeoutMillis,
                ]);
            } else {
                $retryCodesName = $methodConfig['retry_codes_name'];
                $retryParamsName = $methodConfig['retry_params_name'];

                if (!array_key_exists($retryCodesName, $retryCodes)) {
                    throw new ValidationException("Invalid retry_codes_name setting: '$retryCodesName'");
                }
                if (!array_key_exists($retryParamsName, $retryParams)) {
                    throw new ValidationException("Invalid retry_params_name setting: '$retryParamsName'");
                }

                foreach ($retryCodes[$retryCodesName] as $status) {
                    if (!ApiStatus::isValidStatus($status)) {
                        throw new ValidationException("Invalid status code: '$status'");
                    }
                }

                $retryParameters = self::convertArrayFromSnakeCase($retryParams[$retryParamsName]) + [
                    'retryableCodes' => $retryCodes[$retryCodesName],
                    'noRetriesRpcTimeoutMillis' => $timeoutMillis,
                ];
                if ($disableRetries) {
                    $retryParameters['retriesEnabled'] = false;
                }

                $retrySettings = new RetrySettings($retryParameters);
            }

            $serviceRetrySettings[$methodName] = $retrySettings;
        }

        return $serviceRetrySettings;
    }
public static function load(
        $serviceName,
        $clientConfig,
        $disableRetries = false
    ) {
        $serviceRetrySettings = [];

        $serviceConfig = $clientConfig['interfaces'][$serviceName];
        $retryCodes = $serviceConfig['retry_codes'];
        $retryParams = $serviceConfig['retry_params'];
        foreach ($serviceConfig['methods'] as $methodName => $methodConfig) {
            $timeoutMillis = $methodConfig['timeout_millis'];

            if (empty($methodConfig['retry_codes_name']) || empty($methodConfig['retry_params_name'])) {
                // Construct a RetrySettings object with retries disabled
                $retrySettings = self::constructDefault()->with([
                    'noRetriesRpcTimeoutMillis' => $timeoutMillis,
                ]);
            } else {
                $retryCodesName = $methodConfig['retry_codes_name'];
                $retryParamsName = $methodConfig['retry_params_name'];

                if (!array_key_exists($retryCodesName, $retryCodes)) {
                    throw new ValidationException("Invalid retry_codes_name setting: '$retryCodesName'");
                }
                if (!array_key_exists($retryParamsName, $retryParams)) {
                    throw new ValidationException("Invalid retry_params_name setting: '$retryParamsName'");
                }

                foreach ($retryCodes[$retryCodesName] as $status) {
                    if (!ApiStatus::isValidStatus($status)) {
                        throw new ValidationException("Invalid status code: '$status'");
                    }
                }

                $retryParameters = self::convertArrayFromSnakeCase($retryParams[$retryParamsName]) + [
                    'retryableCodes' => $retryCodes[$retryCodesName],
                    'noRetriesRpcTimeoutMillis' => $timeoutMillis,
                ];
                if ($disableRetries) {
                    $retryParameters['retriesEnabled'] = false;
                }

                $retrySettings = new RetrySettings($retryParameters);
            }

            $serviceRetrySettings[$methodName] = $retrySettings;
        }

        return $serviceRetrySettings;
    }
public static function load ( $ serviceName , $ clientConfig , $ disableRetries = false ) { $ serviceRetrySettings = [ ] ; $ serviceConfig = $ clientConfig [ 'interfaces' ] [ $ serviceName ] ; $ retryCodes = $ serviceConfig [ 'retry_codes' ] ; $ retryParams = $ serviceConfig [ 'retry_params' ] ; foreach ( $ serviceConfig [ 'methods' ] as $ methodName => $ methodConfig ) { $ timeoutMillis = $ methodConfig [ 'timeout_millis' ] ; if ( empty ( $ methodConfig [ 'retry_codes_name' ] ) || empty ( $ methodConfig [ 'retry_params_name' ] ) ) { // Construct a RetrySettings object with retries disabled $ retrySettings = self :: constructDefault ( ) -> with ( [ 'noRetriesRpcTimeoutMillis' => $ timeoutMillis , ] ) ; } else { $ retryCodesName = $ methodConfig [ 'retry_codes_name' ] ; $ retryParamsName = $ methodConfig [ 'retry_params_name' ] ; if ( ! array_key_exists ( $ retryCodesName , $ retryCodes ) ) { throw new ValidationException ( "Invalid retry_codes_name setting: '$retryCodesName'" ) ; } if ( ! array_key_exists ( $ retryParamsName , $ retryParams ) ) { throw new ValidationException ( "Invalid retry_params_name setting: '$retryParamsName'" ) ; } foreach ( $ retryCodes [ $ retryCodesName ] as $ status ) { if ( ! ApiStatus :: isValidStatus ( $ status ) ) { throw new ValidationException ( "Invalid status code: '$status'" ) ; } } $ retryParameters = self :: convertArrayFromSnakeCase ( $ retryParams [ $ retryParamsName ] ) + [ 'retryableCodes' => $ retryCodes [ $ retryCodesName ] , 'noRetriesRpcTimeoutMillis' => $ timeoutMillis , ] ; if ( $ disableRetries ) { $ retryParameters [ 'retriesEnabled' ] = false ; } $ retrySettings = new RetrySettings ( $ retryParameters ) ; } $ serviceRetrySettings [ $ methodName ] = $ retrySettings ; } return $ serviceRetrySettings ; }
Constructs an array mapping method names to CallSettings.

@param string $serviceName
The fully-qualified name of this service, used as a key into
the client config file.
@param array $clientConfig
An array parsed from the standard API client config file.
@param bool $disableRetries
Disable retries in all loaded RetrySettings objects. Defaults to false.
@throws ValidationException
@return RetrySettings[] $retrySettings
Constructs an array mapping method names to CallSettings .