Module: OCI::LoadBalancer::Util

Defined in:
lib/oci/load_balancer/util.rb

Overview

Load balancer utility methods

Class Method Summary collapse

Class Method Details

.wait_on_work_request(client, work_request_id, max_interval_seconds: 30, max_wait_seconds: 1200, raise_error_on_failure: true) ⇒ OCI::Response

Wait until the work request succeeds or fails, or max_wait_seconds is reached. The work request will be polled at an increasing rate, with a maximum of max_interval_seconds between requests.

raised if the work request is in a failed state. Models::WorkRequest

Parameters:

  • client (LoadBalancerClient)

    A load balancer client

  • max_interval_seconds (Integer) (defaults to: 30)

    The maximum interval between queries, in seconds.

  • max_wait_seconds (Integer) (defaults to: 1200)

    The maximum total time to wait, in seconds.

  • raise_error_on_failure (Boolean) (defaults to: true)

    If true, then a WorkRequestFailedError will be

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/oci/load_balancer/util.rb', line 19

def self.wait_on_work_request(client,
                              work_request_id,
                              max_interval_seconds: 30,
                              max_wait_seconds: 1200,
                              raise_error_on_failure: true)
  OCI::Waiter::WorkRequest.wait_for_state(
    client,
    work_request_id,
    lambda do |work_request|
      work_request.lifecycle_state == OCI::LoadBalancer::Models::WorkRequest::LIFECYCLE_STATE_SUCCEEDED
    end,
    lambda do |work_request|
      is_failed_state = work_request.lifecycle_state == \
        OCI::LoadBalancer::Models::WorkRequest::LIFECYCLE_STATE_FAILED
      raise OCI::Errors::WorkRequestFailedError.new(work_request, work_request.lifecycle_state) \
        if raise_error_on_failure && is_failed_state

      is_failed_state
    end,
    max_interval_seconds: max_interval_seconds,
    max_wait_seconds: max_wait_seconds
  )
end