Module: Phronomy::Agent::Concerns::Retryable::ClassMethods Private

Defined in:
lib/phronomy/agent/concerns/retryable.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class-level DSL methods mixed into the including agent class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_retry_policyHash? (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the configured retry policy, or nil when none is set.

Returns:

  • (Hash, nil)


36
37
38
# File 'lib/phronomy/agent/concerns/retryable.rb', line 36

def _retry_policy
  @_retry_policy
end

#_sleep_proc#call

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Injectable sleep callable for testing (shared with Tool::Base pattern).

Returns:

  • (#call)


41
42
43
# File 'lib/phronomy/agent/concerns/retryable.rb', line 41

def _sleep_proc
  @_sleep_proc || method(:sleep)
end

Instance Method Details

#retry_policy(times: 0, wait: 0, base: 1.0) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Configures a retry policy that wraps the full #invoke call. GuardrailError is never retried regardless of this setting.

Examples:

class MyAgent < Phronomy::Agent::Base
  retry_policy times: 2, wait: :exponential, base: 1.0
end

Parameters:

  • times (Integer) (defaults to: 0)

    maximum retry attempts (default: 0)

  • wait (Symbol, Numeric) (defaults to: 0)

    :exponential, :linear, or a fixed Float

  • base (Float) (defaults to: 1.0)

    base wait time in seconds (default: 1.0)



30
31
32
# File 'lib/phronomy/agent/concerns/retryable.rb', line 30

def retry_policy(times: 0, wait: 0, base: 1.0)
  @_retry_policy = {times: times, wait: wait, base: base}
end