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.
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.
- retry_policy (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.
- (PollingHarness) — a new instance of PollingHarness
#retry_policy
def retry_policy() -> Gapic::Common::RetryPolicy
- (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.
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 is raised, it is propagated out. If
the timeout expires, the given timeout result (normally nil
) is
returned.
-
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
.