ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Registry.Backoff

Description

Process-local public authority cooldowns with one owned recovery request.

Synopsis

Documentation

reportingBackoff :: (HostPort -> CooldownEvent -> IO ()) -> PublicBackoff -> PublicBackoff Source #

Attach a non-throwing observer. Notifications run after the state transaction commits.

data CooldownEvent Source #

A cooldown opens or a response restores the authority to healthy service.

Constructors

CoolingDown 
Recovered 

publicRetryAfter :: PublicBackoff -> HostPort -> IO (Maybe RetryAfter) Source #

Read the remaining refusal hint without acquiring a recovery probe.

data PublicBackoff Source #

Share one handle across all public readers. Only pass authorities approved by the public egress policy.

newPublicBackoff :: IO UTCTime -> (RetryAfter -> RetryAfter -> IO RetryAfter) -> IO PublicBackoff Source #

Use the fixed public policy with a fresh clock and jitter selector, clamped to the current fallback interval.

data PublicAttempt Source #

An admitted request may settle once. Its enclosing callback owns its lifetime.

withPublicAttempt :: PublicBackoff -> HostPort -> (PublicAttempt -> IO a) -> IO (Either RetryAfter a) Source #

Refuse a cooling authority without running the callback. Every exit releases an unsettled recovery probe.

data PublicResponse Source #

The caller classifies status and parses any retry hint before reporting the response headers.

Constructors

NonThrottling 
Throttled (Maybe RetryAfter)

A supplied hint must already respect the caller's honoured-header cap. Missing hints use fallback.

recordPublicResponse :: PublicAttempt -> PublicResponse -> IO () Source #

Commit response headers before consuming the body. Repeated calls and calls after the callback ends leave state unchanged.