← All changes
|
includes/sdk/google/google/gax/src/RetrySettings.php
+13
-13
1.2.13
→
1.4.2
View file →
| @@ -29,9 +29,9 @@ | ||
| 29 | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 30 | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 31 | 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | 32 | */ |
| 33 | -namespace Dudlewebs\WPMCS\Google\ApiCore; | |
| 33 | +namespace Dudlewebs\WPMCS\GCP\Google\ApiCore; | |
| 34 | 34 | |
| 35 | 35 | use Closure; |
| 36 | 36 | /** |
| 37 | 37 | * The RetrySettings class is used to configure retrying and timeouts for RPCs. |
| @@ -76,9 +76,9 @@ | ||
| 76 | 76 | * |
| 77 | 77 | * RetrySettings objects can be used to control retries for many RPC methods in |
| 78 | 78 | * [google-cloud-php](https://github.com/googleapis/google-cloud-php). |
| 79 | 79 | * The examples below make use of the |
| 80 | - * [GroupServiceClient](https://googleapis.github.io/google-cloud-php/#/docs/google-cloud/monitoring/v3/groupserviceclient) | |
| 80 | + * [GroupServiceClient](https://cloud.google.com/php/docs/reference/cloud-monitoring/latest/V3.Client.GroupServiceClient) | |
| 81 | 81 | * from the [Monitoring V3 API](https://github.com/googleapis/google-cloud-php/tree/master/src/Monitoring/V3), |
| 82 | 82 | * but they can be applied to other APIs in the |
| 83 | 83 | * [google-cloud-php](https://github.com/googleapis/google-cloud-php) repository. |
| 84 | 84 | * |
| @@ -87,9 +87,9 @@ | ||
| 87 | 87 | * field can contain either a RetrySettings object, or a PHP array containing |
| 88 | 88 | * the particular retry parameters to be updated. |
| 89 | 89 | * |
| 90 | 90 | * Example of disabling retries for a single call to the |
| 91 | - * [listGroups](https://googleapis.github.io/google-cloud-php/#/docs/google-cloud/monitoring/v3/groupserviceclient?method=listGroups) | |
| 91 | + * [listGroups](https://cloud.google.com/php/docs/reference/cloud-monitoring/latest/V3.Client.GroupServiceClient#_Google_Cloud_Monitoring_V3_Client_GroupServiceClient__listGroups__) | |
| 92 | 92 | * method, and setting a custom timeout: |
| 93 | 93 | * ``` |
| 94 | 94 | * $result = $client->listGroups($name, [ |
| 95 | 95 | * 'retrySettings' => [ |
| @@ -100,9 +100,9 @@ | ||
| 100 | 100 | * ``` |
| 101 | 101 | * |
| 102 | 102 | * Example of creating a new RetrySettings object and using it to override |
| 103 | 103 | * the retry settings for a call to the |
| 104 | - * [listGroups](https://googleapis.github.io/google-cloud-php/#/docs/google-cloud/monitoring/v3/groupserviceclient?method=listGroups) | |
| 104 | + * [listGroups](https://cloud.google.com/php/docs/reference/cloud-monitoring/latest/V3.Client.GroupServiceClient#_Google_Cloud_Monitoring_V3_Client_GroupServiceClient__listGroups__) | |
| 105 | 105 | * method: |
| 106 | 106 | * ``` |
| 107 | 107 | * $customRetrySettings = new RetrySettings([ |
| 108 | 108 | * 'initialRetryDelayMillis' => 100, |
| @@ -125,10 +125,10 @@ | ||
| 125 | 125 | * |
| 126 | 126 | * It is also possible to specify the retry behavior for RPC methods when |
| 127 | 127 | * constructing a client object using the 'retrySettingsArray'. The examples |
| 128 | 128 | * below again make use of the |
| 129 | - * [GroupServiceClient](https://googleapis.github.io/google-cloud-php/#/docs/google-cloud/monitoring/v3/groupserviceclient) | |
| 130 | - * from the [Monitoring V3 API](https://github.com/googleapis/google-cloud-php/tree/master/src/Monitoring/V3), | |
| 129 | + * [GroupServiceClient](https://cloud.google.com/php/docs/reference/cloud-monitoring/latest/V3.Client.GroupServiceClient) | |
| 130 | + * from the [Monitoring V3 API](https://github.com/googleapis/google-cloud-php/tree/main/Monitoring/src/V3), | |
| 131 | 131 | * but they can be applied to other APIs in the |
| 132 | 132 | * [google-cloud-php](https://github.com/googleapis/google-cloud-php) repository. |
| 133 | 133 | * |
| 134 | 134 | * The GroupServiceClient object accepts an optional `retrySettingsArray` |
| @@ -260,9 +260,9 @@ | ||
| 260 | 260 | * } |
| 261 | 261 | */ |
| 262 | 262 | public function __construct(array $settings) |
| 263 | 263 | { |
| 264 | - $this->validateNotNull($settings, ['initialRetryDelayMillis', 'retryDelayMultiplier', 'maxRetryDelayMillis', 'initialRpcTimeoutMillis', 'rpcTimeoutMultiplier', 'maxRpcTimeoutMillis', 'totalTimeoutMillis', 'retryableCodes']); | |
| 264 | + self::validateNotNull($settings, ['initialRetryDelayMillis', 'retryDelayMultiplier', 'maxRetryDelayMillis', 'initialRpcTimeoutMillis', 'rpcTimeoutMultiplier', 'maxRpcTimeoutMillis', 'totalTimeoutMillis', 'retryableCodes']); | |
| 265 | 265 | $this->initialRetryDelayMillis = $settings['initialRetryDelayMillis']; |
| 266 | 266 | $this->retryDelayMultiplier = $settings['retryDelayMultiplier']; |
| 267 | 267 | $this->maxRetryDelayMillis = $settings['maxRetryDelayMillis']; |
| 268 | 268 | $this->initialRpcTimeoutMillis = $settings['initialRpcTimeoutMillis']; |
| @@ -269,10 +269,10 @@ | ||
| 269 | 269 | $this->rpcTimeoutMultiplier = $settings['rpcTimeoutMultiplier']; |
| 270 | 270 | $this->maxRpcTimeoutMillis = $settings['maxRpcTimeoutMillis']; |
| 271 | 271 | $this->totalTimeoutMillis = $settings['totalTimeoutMillis']; |
| 272 | 272 | $this->retryableCodes = $settings['retryableCodes']; |
| 273 | - $this->retriesEnabled = array_key_exists('retriesEnabled', $settings) ? $settings['retriesEnabled'] : count($this->retryableCodes) > 0; | |
| 274 | - $this->noRetriesRpcTimeoutMillis = array_key_exists('noRetriesRpcTimeoutMillis', $settings) ? $settings['noRetriesRpcTimeoutMillis'] : $this->initialRpcTimeoutMillis; | |
| 273 | + $this->retriesEnabled = \array_key_exists('retriesEnabled', $settings) ? $settings['retriesEnabled'] : \count($this->retryableCodes) > 0; | |
| 274 | + $this->noRetriesRpcTimeoutMillis = \array_key_exists('noRetriesRpcTimeoutMillis', $settings) ? $settings['noRetriesRpcTimeoutMillis'] : $this->initialRpcTimeoutMillis; | |
| 275 | 275 | $this->maxRetries = $settings['maxRetries'] ?? self::DEFAULT_MAX_RETRIES; |
| 276 | 276 | $this->retryFunction = $settings['retryFunction'] ?? null; |
| 277 | 277 | } |
| 278 | 278 | /** |
| @@ -301,12 +301,12 @@ | ||
| 301 | 301 | $retrySettings = self::constructDefault()->with(['noRetriesRpcTimeoutMillis' => $timeoutMillis]); |
| 302 | 302 | } else { |
| 303 | 303 | $retryCodesName = $methodConfig['retry_codes_name']; |
| 304 | 304 | $retryParamsName = $methodConfig['retry_params_name']; |
| 305 | - if (!array_key_exists($retryCodesName, $retryCodes)) { | |
| 305 | + if (!\array_key_exists($retryCodesName, $retryCodes)) { | |
| 306 | 306 | throw new ValidationException("Invalid retry_codes_name setting: '{$retryCodesName}'"); |
| 307 | 307 | } |
| 308 | - if (!array_key_exists($retryParamsName, $retryParams)) { | |
| 308 | + if (!\array_key_exists($retryParamsName, $retryParams)) { | |
| 309 | 309 | throw new ValidationException("Invalid retry_params_name setting: '{$retryParamsName}'"); |
| 310 | 310 | } |
| 311 | 311 | foreach ($retryCodes[$retryCodesName] as $status) { |
| 312 | 312 | if (!ApiStatus::isValidStatus($status)) { |
| @@ -453,10 +453,10 @@ | ||
| 453 | 453 | private static function convertArrayFromSnakeCase(array $settings) |
| 454 | 454 | { |
| 455 | 455 | $camelCaseSettings = []; |
| 456 | 456 | foreach ($settings as $key => $value) { |
| 457 | - $camelCaseKey = str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); | |
| 458 | - $camelCaseSettings[lcfirst($camelCaseKey)] = $value; | |
| 457 | + $camelCaseKey = \str_replace(' ', '', \ucwords(\str_replace('_', ' ', $key))); | |
| 458 | + $camelCaseSettings[\lcfirst($camelCaseKey)] = $value; | |
| 459 | 459 | } |
| 460 | 460 | return $camelCaseSettings; |
| 461 | 461 | } |
| 462 | 462 | } |