1.5.0 (latest) 1.4.1 1.3.0 1.2.0 1.1.0 1.0.1 0.26.0 0.25.0 0.24.0 Reference documentation and code samples for the gapic-common class Gapic::Common::PollingHarness.

Provides a generic mechanism for periodic polling an operation.


Polling intervals are calculated from the provided retry policy.

<br />

Supports exponential backoff via `multiplier`, and automatically
retries gRPC errors listed in `retry_codes`.

## Inherits

- Object

## Methods

### #initialize

    def initialize(retry_policy: nil, **kwargs) -> PollingHarness

Create new Gapic::Common::PollingHarness instance.
**Parameters**

- **retry_policy** ([Gapic::Common::RetryPolicy](https://docs.cloud.google.com/ruby/docs/reference/gapic-common/latest/Gapic-Common-RetryPolicy)) *(defaults to: nil)* --- The retry policy to use. If not provided, a new retry policy is constructed from the given kwargs.
- **kwargs** (keywords) --- Keyword arguments used to create a new retry policy. See [RetryPolicy#initialize](https://docs.cloud.google.com/ruby/docs/reference/gapic-common/latest/Gapic-Common-RetryPolicy#Gapic__Common__RetryPolicy_initialize_instance_ "Gapic::Common::RetryPolicy#initialize (method)").
**Returns**

- ([PollingHarness](https://docs.cloud.google.com/ruby/docs/reference/gapic-common/latest/Gapic-Common-PollingHarness)) --- a new instance of PollingHarness

### #retry_policy

    def retry_policy() -> Gapic::Common::RetryPolicy

**Returns**

- ([Gapic::Common::RetryPolicy](https://docs.cloud.google.com/ruby/docs/reference/gapic-common/latest/Gapic-Common-RetryPolicy)) --- The retry policy associated with this instance.

### #wait

    def wait(wait_sentinel: nil, timeout_result: nil, mock_delay: false)

Perform polling with exponential backoff. Repeatedly calls the given
block until it returns a result other than the given sentinel value
(normally `nil`), then returns that final result.


<br />

Uses the retry policy regulate retries, including delays between tries,
retriable errors, and final timeout. If an error code other than those
listed in [RetryPolicy#retry_codes](https://docs.cloud.google.com/ruby/docs/reference/gapic-common/latest/Gapic-Common-RetryPolicy#Gapic__Common__RetryPolicy_retry_codes_instance_ "Gapic::Common::RetryPolicy#retry_codes (method)") is raised, it is propagated out. If
the timeout expires, the given timeout result (normally `nil`) is
returned.
**Parameters**

- **wait_sentinel** (Object) *(defaults to: nil)* --- The return value that should signal the polling harness to continue waiting. Any other value is treated as a real result and returned. Defaults to `nil`.
- **timeout_result** (Object) *(defaults to: nil)* --- The result to return if timeout occurs. Defaults to `nil`.