AgentSea.Gateway.CircuitBreaker (agentsea_gateway v0.1.0)

Copy Markdown

Per-provider circuit breaker on top of the battle-tested :fuse library.

Each provider gets a fuse. A failed call melt/1s it; once it has melted past its tolerance within the window the fuse is "blown" and the gateway skips that provider until it resets. We don't hand-roll the closed/open/half-open state machine — :fuse already has it.

Summary

Functions

Whether the provider's circuit is currently usable.

Install the provider's fuse if it isn't already present.

Record a failure against the provider's fuse.

Remove the provider's fuse (e.g. on gateway shutdown / test cleanup).

Functions

ask(name)

@spec ask(term()) :: :ok | :blown

Whether the provider's circuit is currently usable.

ensure(name)

@spec ensure(term()) :: :ok | :reset | {:error, term()}

Install the provider's fuse if it isn't already present.

melt(name)

@spec melt(term()) :: :ok

Record a failure against the provider's fuse.

remove(name)

@spec remove(term()) :: :ok

Remove the provider's fuse (e.g. on gateway shutdown / test cleanup).