ExWapp.Session.Worker.Safety (ExWapp v0.1.2)

Copy Markdown View Source

Implements the session's outbound safety circuit breaker.

It records server-side risk signals, applies configurable cool-off windows, and can lock sending after forbidden responses until the session is reset.

Summary

Types

state_data()

@type state_data() :: %{
  counters: %{optional(atom()) => [integer()]},
  blocked_until_ms: integer() | nil,
  forbidden: boolean(),
  last_trip_reason: atom() | nil
}

Functions

check_send_allowed(state)

@spec check_send_allowed(ExWapp.Session.Worker.t()) ::
  {:ok, ExWapp.Session.Worker.t()} | {:error, term(), ExWapp.Session.Worker.t()}

new()

@spec new() :: state_data()

record_signal(state, signal)

@spec record_signal(ExWapp.Session.Worker.t(), atom()) :: ExWapp.Session.Worker.t()

status(state)

@spec status(ExWapp.Session.Worker.t()) :: map()