Module: Appom::Retry

Defined in:
lib/appom/retry.rb

Overview

Retry functionality for Appom automation framework Provides exponential backoff retry logic for flaky operations

Defined Under Namespace

Modules: RetryMethods Classes: RetryConfig

Constant Summary collapse

DEFAULT_RETRY_COUNT =

Default retry configuration

3
DEFAULT_RETRY_DELAY =
0.5
DEFAULT_BACKOFF_MULTIPLIER =
1.5

Class Method Summary collapse

Class Method Details

.configure_element_retry {|config| ... } ⇒ Object

Configure retry behavior for element operations

Yields:

  • (config)


55
56
57
58
59
# File 'lib/appom/retry.rb', line 55

def configure_element_retry
  config = RetryConfig.new
  yield(config) if block_given?
  config
end

.with_retry(config = RetryConfig.new) ⇒ Object

Execute a block with retry logic



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/appom/retry.rb', line 30

def with_retry(config = RetryConfig.new)
  return unless block_given?

  attempt = 1
  delay = config.base_delay

  begin
    yield
  rescue *config.retry_on_exceptions => e
    # Check if we should retry based on custom condition
    raise e if config.retry_if && !config.retry_if.call(e, attempt)

    raise e unless attempt < config.max_attempts

    # Call retry callback if provided
    config.on_retry&.call(e, attempt, delay)

    Kernel.sleep(delay)
    attempt += 1
    delay = [delay * config.backoff_multiplier, config.max_delay].min
    retry
  end
end