HttpRetryPolicy.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. /*
  3. * Copyright 2014 Google Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  6. * use this file except in compliance with the License. You may obtain a copy of
  7. * the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. * License for the specific language governing permissions and limitations under
  15. * the License.
  16. */
  17. namespace Google\Service\Compute;
  18. class HttpRetryPolicy extends \Google\Collection
  19. {
  20. protected $collection_key = 'retryConditions';
  21. /**
  22. * Specifies the allowed number retries. This number must be > 0. If not
  23. * specified, defaults to 1.
  24. *
  25. * @var string
  26. */
  27. public $numRetries;
  28. protected $perTryTimeoutType = Duration::class;
  29. protected $perTryTimeoutDataType = '';
  30. /**
  31. * Specifies one or more conditions when this retry policy applies. Valid
  32. * values are: - 5xx: retry is attempted if the instance or endpoint
  33. * responds with any 5xx response code, or if the instance or endpoint does
  34. * not respond at all. For example, disconnects, reset, read timeout,
  35. * connection failure, and refused streams. - gateway-error: Similar to
  36. * 5xx, but only applies to response codes 502, 503 or504. - connect-
  37. * failure: a retry is attempted on failures connecting to the instance or
  38. * endpoint. For example, connection timeouts. - retriable-4xx: a retry
  39. * is attempted if the instance or endpoint responds with a 4xx response
  40. * code. The only error that you can retry is error code 409. - refused-
  41. * stream: a retry is attempted if the instance or endpoint resets the
  42. * stream with a REFUSED_STREAM error code. This reset type indicates that
  43. * it is safe to retry. - cancelled: a retry is attempted if the gRPC
  44. * status code in the response header is set to cancelled. - deadline-
  45. * exceeded: a retry is attempted if the gRPC status code in the response
  46. * header is set todeadline-exceeded. - internal: a retry is attempted if
  47. * the gRPC status code in the response header is set tointernal. -
  48. * resource-exhausted: a retry is attempted if the gRPC status code in the
  49. * response header is set toresource-exhausted. - unavailable: a retry is
  50. * attempted if the gRPC status code in the response header is set
  51. * tounavailable.
  52. *
  53. * Only the following codes are supported when the URL map is bound to target
  54. * gRPC proxy that has validateForProxyless field set to true. -
  55. * cancelled - deadline-exceeded - internal - resource-exhausted -
  56. * unavailable
  57. *
  58. * @var string[]
  59. */
  60. public $retryConditions;
  61. /**
  62. * Specifies the allowed number retries. This number must be > 0. If not
  63. * specified, defaults to 1.
  64. *
  65. * @param string $numRetries
  66. */
  67. public function setNumRetries($numRetries)
  68. {
  69. $this->numRetries = $numRetries;
  70. }
  71. /**
  72. * @return string
  73. */
  74. public function getNumRetries()
  75. {
  76. return $this->numRetries;
  77. }
  78. /**
  79. * Specifies a non-zero timeout per retry attempt.
  80. *
  81. * If not specified, will use the timeout set in theHttpRouteAction field. If
  82. * timeout in the HttpRouteAction field is not set, this field uses the
  83. * largest timeout among all backend services associated with the route.
  84. *
  85. * Not supported when the URL map is bound to a target gRPC proxy that has the
  86. * validateForProxyless field set to true.
  87. *
  88. * @param Duration $perTryTimeout
  89. */
  90. public function setPerTryTimeout(Duration $perTryTimeout)
  91. {
  92. $this->perTryTimeout = $perTryTimeout;
  93. }
  94. /**
  95. * @return Duration
  96. */
  97. public function getPerTryTimeout()
  98. {
  99. return $this->perTryTimeout;
  100. }
  101. /**
  102. * Specifies one or more conditions when this retry policy applies. Valid
  103. * values are: - 5xx: retry is attempted if the instance or endpoint
  104. * responds with any 5xx response code, or if the instance or endpoint does
  105. * not respond at all. For example, disconnects, reset, read timeout,
  106. * connection failure, and refused streams. - gateway-error: Similar to
  107. * 5xx, but only applies to response codes 502, 503 or504. - connect-
  108. * failure: a retry is attempted on failures connecting to the instance or
  109. * endpoint. For example, connection timeouts. - retriable-4xx: a retry
  110. * is attempted if the instance or endpoint responds with a 4xx response
  111. * code. The only error that you can retry is error code 409. - refused-
  112. * stream: a retry is attempted if the instance or endpoint resets the
  113. * stream with a REFUSED_STREAM error code. This reset type indicates that
  114. * it is safe to retry. - cancelled: a retry is attempted if the gRPC
  115. * status code in the response header is set to cancelled. - deadline-
  116. * exceeded: a retry is attempted if the gRPC status code in the response
  117. * header is set todeadline-exceeded. - internal: a retry is attempted if
  118. * the gRPC status code in the response header is set tointernal. -
  119. * resource-exhausted: a retry is attempted if the gRPC status code in the
  120. * response header is set toresource-exhausted. - unavailable: a retry is
  121. * attempted if the gRPC status code in the response header is set
  122. * tounavailable.
  123. *
  124. * Only the following codes are supported when the URL map is bound to target
  125. * gRPC proxy that has validateForProxyless field set to true. -
  126. * cancelled - deadline-exceeded - internal - resource-exhausted -
  127. * unavailable
  128. *
  129. * @param string[] $retryConditions
  130. */
  131. public function setRetryConditions($retryConditions)
  132. {
  133. $this->retryConditions = $retryConditions;
  134. }
  135. /**
  136. * @return string[]
  137. */
  138. public function getRetryConditions()
  139. {
  140. return $this->retryConditions;
  141. }
  142. }
  143. // Adding a class alias for backwards compatibility with the previous class name.
  144. class_alias(HttpRetryPolicy::class, 'Google_Service_Compute_HttpRetryPolicy');