Noizu.Comms.Policy (noizu_comms v0.1.0)

Copy Markdown View Source

Write policy: alias allow-list, raw-target gate, per-target rate limit.

  • Alias targets (resolved from the targets YAML) must have allow_write: true.
  • Raw URIs are refused unless COMMS_ALLOW_RAW_TARGETS=1 (or app env :noizu_comms, :allow_raw_targets, true).
  • Per-target token bucket, default 5 messages / 10 s (app env :noizu_comms, :rate_limit, {cap, window_ms}).

The bucket lives in a public ETS table with lazy refill; clock and sleep are injectable via app env :now_fn / :sleep_fn for tests. Concurrent senders may double-refill at the bucket boundary (bounded: at most cap - 1 extra messages per window under full contention).

Summary

Functions

Checks target for action (only :write is gated in v1).

Drops the rate-limit table (test helper; recreated on next check).

Functions

check(target, action \\ :write)

@spec check(Noizu.Comms.Target.t(), atom()) :: :ok | {:error, Noizu.Comms.Error.t()}

Checks target for action (only :write is gated in v1).

reset()

@spec reset() :: true

Drops the rate-limit table (test helper; recreated on next check).