Slink.Rate (Slink v0.1.0)

Copy Markdown View Source

Per-channel outbound rate limiting for Slack Web API calls.

Slack limits chat.postMessage to roughly one message per second per channel; bursts beyond that get 429s and dropped messages. This module fronts outbound calls with one lightweight GenServer per channel (see Slink.Rate.Channel), each draining a FIFO queue no faster than the configured interval. Different channels drain concurrently.

Calls are fire-and-forget: failures are logged, not returned. Use Slink.API directly if you need the response.

Configuration

  • config :slink, :rate_interval_ms, 1_000 — minimum gap between sends on a single channel (default 1000ms).

Summary

Functions

Queue any Web API method targeting channel, rate-limited per channel.

Queue a chat.postMessage for channel, rate-limited per channel.

Functions

enqueue(bot_token, channel, method, params)

@spec enqueue(String.t(), String.t(), String.t(), map()) :: :ok

Queue any Web API method targeting channel, rate-limited per channel.

post_message(bot_token, channel, text, opts \\ %{})

@spec post_message(String.t(), String.t(), String.t(), map()) :: :ok

Queue a chat.postMessage for channel, rate-limited per channel.