You're asking for a sketch of the proxy-service pattern to manage global webhook endpoints dynamically. Below is a concise design and implementation outline you can adapt.
Design overview
• LiveKit → sends events to a single static webhook URL (configured in livekit.yaml).
• Proxy service → receives LiveKit events, verifies signature if used, looks up registered target endpoints from a datastore, and forwards events to those endpoints (optionally signing/transforming).
• Admin API/UI → lets you add/remove target endpoints stored in the datastore without changing LiveKit config.
• Datastore → stores webhook targets with metadata (url, enabled, event filters, signing key, retry policy).
• Worker/Queue → handles delivery retries, backoff, and failures asynchronously.
Minimal data model (example)
• id
• url
• enabled (bool)
• events (list of event types to receive, or null for all)
• signing_key (optional, used to sign forwarded requests)
• retry_policy (max_retries, backoff)
• last_status, last_error, created_at, updated_at
Proxy behavior (request flow)
1. Receive request from LiveKit at /livekit/webhook.
2. Verify signature (if LiveKit signs events) using configured verification key.
3. Parse event type and payload.
4. Query datastore for enabled targets matching the event type.
5. Enqueue delivery tasks for each target (push job into queue).
6. Respond 200 to LiveKit quickly to avoid timeouts.
Delivery worker behavior
1. Pop delivery job (contains target, payload, headers).
2. Optionally sign or add identifying headers (e.g., X-Forwarded-From, X-Signature).
3. POST to target.url with payload and headers.
4. On failure, record error, update last_status, and retry per retry_policy using backoff.
5. If permanently failed, mark disabled or alert admins.
Security and reliability notes
• Verify LiveKit signatures to avoid spoofing.
• Rate-limit outgoing deliveries and queue large fan-outs.
• Use idempotency keys or retries with deduplication to avoid duplicate processing.
• Encrypt signing keys at rest; restrict access to datastore.
• Expose metrics and logs for delivery success/failure rates.
• Consider webhook batching or sampling if fan‑out is very large.
Simple implementation sketch (endpoints)
• POST /livekit/webhook — receives LiveKit events.
• POST /admin/webhooks — add webhook target.
• GET /admin/webhooks — list targets.
• PATCH /admin/webhooks/{id} — update enable/disable, filters.
• DELETE /admin/webhooks/{id} — remove target.
Example delivery task payload (worker) { "target_id": "abc", "url": "
https://example.com/hook", "payload": { "event": "...", "data": {...} }, "headers": { "X-Forwarded-From": "livekit-proxy" }, "attempt": 0 }
Operational recommendations
• Start with synchronous forwarding and limited concurrency for small scale; move to queued workers as scale grows.
• Implement exponential backoff with jitter for retries.
• Provide a dashboard showing delivery history and failures for each target.
• Optionally allow per-target event filters to reduce unnecessary deliveries.
Would you like a small code example in Node.js or Go for the proxy receiver + worker enqueue?