Pristine.Ports.Retry behaviour (Pristine v0.4.0)

Copy Markdown View Source

Retry boundary for retrying operations.

Required callback:

  • with_retry/2 - Execute a function with retry semantics

Optional callbacks for HTTP-specific features:

  • should_retry?/1 - Determine if a response should be retried
  • parse_retry_after/1 - Extract retry delay from response headers

Summary

Callbacks

Build a backoff policy struct from keyword options.

Build a retry policy struct from keyword options.

Parse retry delay from HTTP response headers. Returns delay in milliseconds, or nil if not available.

Determine if an HTTP response should be retried based on status code and headers.

Callbacks

build_backoff(keyword)

(optional)
@callback build_backoff(keyword()) :: term()

Build a backoff policy struct from keyword options.

build_policy(keyword)

(optional)
@callback build_policy(keyword()) :: term()

Build a retry policy struct from keyword options.

parse_retry_after(map)

(optional)
@callback parse_retry_after(map()) :: non_neg_integer() | nil

Parse retry delay from HTTP response headers. Returns delay in milliseconds, or nil if not available.

should_retry?(map)

(optional)
@callback should_retry?(map()) :: boolean()

Determine if an HTTP response should be retried based on status code and headers.

with_retry(function, keyword)

@callback with_retry((-> term()), keyword()) :: term()