GelotvBot.RateLimiter (GeloTVBot v0.1.0)

Copy Markdown View Source

Shared token-bucket rate limiter used by all bot instances.

reserve/3 returns how long the caller should wait before sending. Buckets are keyed by target, which lets concurrent bot instances coordinate without serializing unrelated channels.

Summary

Functions

Returns a specification to start this module under a supervisor.

Types

bucket_key()

@type bucket_key() :: term()

rule()

@type rule() :: keyword()

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

reserve(key, rule, server \\ __MODULE__)

@spec reserve(bucket_key(), rule(), GenServer.server()) :: non_neg_integer()

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()