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

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_retry_policyHash? (readonly)

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

Returns:

  • (Hash, nil)


34
35
36
# File 'lib/phronomy/agent/concerns/retryable.rb', line 34

def _retry_policy
  @_retry_policy
end

#_sleep_proc#call

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

Returns:

  • (#call)


38
39
40
# File 'lib/phronomy/agent/concerns/retryable.rb', line 38

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

Instance Method Details

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

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)



28
29
30
# File 'lib/phronomy/agent/concerns/retryable.rb', line 28

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