DripDrop.AdapterHealth (DripDrop v0.1.0)

Copy Markdown View Source

Health-state transitions and ramp-cap math for outbound adapters.

Summary

Functions

Computes today's effective cap for an adapter.

Evaluates one probing adapter for promotion or cooldown.

Evaluates all probing adapters.

Moves a resting adapter into probing when its cooldown has elapsed.

Applies a host-supplied health signal to an adapter.

Transitions an adapter to a new health state.

Functions

effective_cap_today(channel_adapter)

@spec effective_cap_today(Ecto.Schema.t()) :: integer() | nil

Computes today's effective cap for an adapter.

evaluate_probe(adapter)

@spec evaluate_probe(Ecto.Schema.t()) ::
  {:ok, Ecto.Schema.t()} | :ok | {:error, term()}

Evaluates one probing adapter for promotion or cooldown.

evaluate_probes()

@spec evaluate_probes() :: {:ok, non_neg_integer()} | {:error, term()}

Evaluates all probing adapters.

recover_if_due(adapter)

@spec recover_if_due(Ecto.Schema.t()) ::
  {:ok, Ecto.Schema.t()} | :ok | {:error, term()}

Moves a resting adapter into probing when its cooldown has elapsed.

set_external_signal(adapter_id, attrs)

@spec set_external_signal(Ecto.UUID.t(), map()) ::
  {:ok, Ecto.Schema.t()} | {:error, term()}

Applies a host-supplied health signal to an adapter.

transition(adapter, new_state, opts \\ [])

@spec transition(Ecto.Schema.t(), atom() | nil, keyword() | map()) ::
  {:ok, Ecto.Schema.t(), [:state_changed_event]} | {:error, :invalid_transition}

Transitions an adapter to a new health state.