PusherServer.Webhook (pusher_server v0.1.2)

Copy Markdown View Source

Fires webhooks in the same shape Pusher/Reverb send them, so your Laravel app can register a webhook route the way it would for real Pusher:

POST {webhook_url for this instance}
X-Pusher-Key: <app_key>
X-Pusher-Signature: HMAC-SHA256(app_secret, raw_body)

{"time_ms": 1699999999999, "events": [{"name": "channel_occupied", "channel": "..."}]}

Only fires if the instance has a webhook_url configured. Delivery runs in its own process (a Task.start/1), so a slow or dead webhook receiver never blocks a websocket connection.

A failed delivery (network error, timeout, HTTP 5xx, 408 or 429) is retried up to :webhook_retries times (default 3) with a doubling delay starting at :webhook_retry_base_ms (default 1 s). Other 4xx responses are not retried. Retries live in memory: if the node stops meanwhile, pending retries are lost, and retried events can arrive out of order, so receivers should be idempotent. Delivery is at-least-once while the node stays up.

Summary

Functions

Builds the {body, headers} for a webhook payload. Pure — no I/O, easy to test.

Starts delivery in the background (with retries). No-op if this instance has no webhook_url configured.

Functions

build(name, events)

Builds the {body, headers} for a webhook payload. Pure — no I/O, easy to test.

dispatch(name, events)

Starts delivery in the background (with retries). No-op if this instance has no webhook_url configured.