ExWapp.Quota (ExWapp v0.1.2)

Copy Markdown View Source

Tracks configurable daily outbound-message quotas.

The counter state lives in the session worker and is split across the whole session, individual JIDs, and groups. check_and_increment/2 returns the updated worker state and an explicit error when a blocking limit is hit.

Summary

Types

state_data()

@type state_data() :: %{
  period_key: String.t(),
  session_count: non_neg_integer(),
  per_jid: %{optional(String.t()) => non_neg_integer()},
  per_group: %{optional(String.t()) => non_neg_integer()}
}

Functions

check_and_increment(state, jid)

@spec check_and_increment(map(), String.t()) :: {:ok, map()} | {:error, term(), map()}

new(runtime_cfg \\ %{})

@spec new(map()) :: state_data()