Skip to content

Commit 1cfe2cf

Browse files
committed
refactor(discord): align on gateway-only ingestion
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
1 parent 2177ea5 commit 1cfe2cf

File tree

17 files changed

+130
-1618
lines changed

17 files changed

+130
-1618
lines changed

devops/docker/compose/.env.example

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,12 @@
3535
# TROGON_SOURCE_LINEAR_TIMESTAMP_TOLERANCE_SECS=60
3636

3737
# --- Discord Source ---
38-
# TROGON_SOURCE_DISCORD_MODE=gateway # "gateway" (WebSocket, all events) or "webhook" (HTTP, interactions only)
39-
# TROGON_SOURCE_DISCORD_BOT_TOKEN= # required when mode=gateway
38+
# TROGON_SOURCE_DISCORD_BOT_TOKEN=
4039
# TROGON_SOURCE_DISCORD_GATEWAY_INTENTS=guilds,guild_members,guild_messages,guild_message_reactions,direct_messages,message_content,guild_voice_states
41-
# TROGON_SOURCE_DISCORD_PUBLIC_KEY= # required when mode=webhook
4240
# TROGON_SOURCE_DISCORD_SUBJECT_PREFIX=discord
4341
# TROGON_SOURCE_DISCORD_STREAM_NAME=DISCORD
4442
# TROGON_SOURCE_DISCORD_STREAM_MAX_AGE_SECS=604800
4543
# TROGON_SOURCE_DISCORD_NATS_ACK_TIMEOUT_SECS=10
46-
# TROGON_SOURCE_DISCORD_NATS_REQUEST_TIMEOUT_SECS=2
4744

4845
# --- Telegram Source ---
4946
# TROGON_SOURCE_TELEGRAM_WEBHOOK_SECRET=

devops/docker/compose/compose.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,12 @@ services:
3232
TROGON_SOURCE_GITHUB_STREAM_MAX_AGE_SECS: "${TROGON_SOURCE_GITHUB_STREAM_MAX_AGE_SECS:-604800}"
3333
TROGON_SOURCE_GITHUB_NATS_ACK_TIMEOUT_SECS: "${TROGON_SOURCE_GITHUB_NATS_ACK_TIMEOUT_SECS:-10}"
3434

35-
TROGON_SOURCE_DISCORD_MODE: "${TROGON_SOURCE_DISCORD_MODE:-}"
3635
TROGON_SOURCE_DISCORD_BOT_TOKEN: "${TROGON_SOURCE_DISCORD_BOT_TOKEN:-}"
3736
TROGON_SOURCE_DISCORD_GATEWAY_INTENTS: "${TROGON_SOURCE_DISCORD_GATEWAY_INTENTS:-}"
38-
TROGON_SOURCE_DISCORD_PUBLIC_KEY: "${TROGON_SOURCE_DISCORD_PUBLIC_KEY:-}"
3937
TROGON_SOURCE_DISCORD_SUBJECT_PREFIX: "${TROGON_SOURCE_DISCORD_SUBJECT_PREFIX:-discord}"
4038
TROGON_SOURCE_DISCORD_STREAM_NAME: "${TROGON_SOURCE_DISCORD_STREAM_NAME:-DISCORD}"
4139
TROGON_SOURCE_DISCORD_STREAM_MAX_AGE_SECS: "${TROGON_SOURCE_DISCORD_STREAM_MAX_AGE_SECS:-604800}"
4240
TROGON_SOURCE_DISCORD_NATS_ACK_TIMEOUT_SECS: "${TROGON_SOURCE_DISCORD_NATS_ACK_TIMEOUT_SECS:-10}"
43-
TROGON_SOURCE_DISCORD_NATS_REQUEST_TIMEOUT_SECS: "${TROGON_SOURCE_DISCORD_NATS_REQUEST_TIMEOUT_SECS:-2}"
4441

4542
TROGON_SOURCE_SLACK_SIGNING_SECRET: "${TROGON_SOURCE_SLACK_SIGNING_SECRET:-}"
4643
TROGON_SOURCE_SLACK_SUBJECT_PREFIX: "${TROGON_SOURCE_SLACK_SUBJECT_PREFIX:-slack}"

devops/docker/compose/services/trogon-gateway/README.md

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
`trogon-gateway` is the unified inbound pipe for platform events into NATS
44
JetStream. It runs all configured sources in a single process behind a single
5-
HTTP server.
5+
HTTP server, plus the optional Discord gateway runner.
66

77
All webhook sources share one port (default `8080`) and are routed by path
88
prefix:
99

1010
| Source | Webhook path | Required env var |
1111
|---|---|---|
1212
| GitHub | `/github/webhook` | `TROGON_SOURCE_GITHUB_WEBHOOK_SECRET` |
13-
| Discord | `/discord/webhook` | `TROGON_SOURCE_DISCORD_MODE` |
1413
| Slack | `/slack/webhook` | `TROGON_SOURCE_SLACK_SIGNING_SECRET` |
1514
| Telegram | `/telegram/webhook` | `TROGON_SOURCE_TELEGRAM_WEBHOOK_SECRET` |
1615
| GitLab | `/gitlab/webhook` | `TROGON_SOURCE_GITLAB_WEBHOOK_SECRET` |
@@ -38,33 +37,15 @@ cp .env.example .env
3837
docker compose up
3938
```
4039

41-
## Discord modes
42-
43-
Discord supports two mutually exclusive modes via `TROGON_SOURCE_DISCORD_MODE`:
44-
45-
| Mode | Transport | Events | Requires |
46-
|---|---|---|---|
47-
| `gateway` | WebSocket (you connect to Discord) | Everything | `TROGON_SOURCE_DISCORD_BOT_TOKEN` |
48-
| `webhook` | HTTP POST (Discord connects to you) | Interactions only | `TROGON_SOURCE_DISCORD_PUBLIC_KEY` |
49-
50-
### Gateway mode
40+
## Discord gateway
5141

5242
```bash
53-
TROGON_SOURCE_DISCORD_MODE=gateway \
5443
TROGON_SOURCE_DISCORD_BOT_TOKEN=<token> \
5544
docker compose up
5645
```
5746

58-
### Webhook mode
59-
60-
```bash
61-
TROGON_SOURCE_DISCORD_MODE=webhook \
62-
TROGON_SOURCE_DISCORD_PUBLIC_KEY=<hex-key> \
63-
docker compose --profile dev up
64-
```
65-
66-
Find the ngrok tunnel URL in `docker compose logs ngrok`, then set it as
67-
your Discord application's Interactions Endpoint URL (append `/discord/webhook`).
47+
Discord does not use the HTTP ingress or ngrok. It opens an outbound WebSocket
48+
connection to Discord and publishes every gateway event to NATS.
6849

6950
## incident.io webhooks
7051

rsworkspace/Cargo.lock

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rsworkspace/crates/trogon-gateway/README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ How to run the unified ingress gateway that receives source events and publishes
77
`trogon-gateway` starts:
88

99
- One HTTP server for webhook-based sources
10-
- Optional Discord Gateway (WebSocket) runner when Discord is configured in `gateway` mode
10+
- Optional Discord Gateway (WebSocket) runner when Discord is enabled
1111
- JetStream stream provisioning for every enabled source
1212
- Health probes at `GET /-/liveness` and `GET /-/readiness`
1313

@@ -34,7 +34,6 @@ All webhook sources share one HTTP port (`TROGON_GATEWAY_PORT`, default `8080`)
3434
| Source | Route |
3535
|---|---|
3636
| GitHub | `/github/webhook` |
37-
| Discord (webhook mode) | `/discord/webhook` |
3837
| Slack | `/slack/webhook` |
3938
| Telegram | `/telegram/webhook` |
4039
| GitLab | `/gitlab/webhook` |
@@ -47,8 +46,7 @@ A source is enabled only when its required setting is present:
4746
| Source | Required setting |
4847
|---|---|
4948
| GitHub | `TROGON_SOURCE_GITHUB_WEBHOOK_SECRET` |
50-
| Discord (`gateway`) | `TROGON_SOURCE_DISCORD_MODE=gateway` and `TROGON_SOURCE_DISCORD_BOT_TOKEN` |
51-
| Discord (`webhook`) | `TROGON_SOURCE_DISCORD_MODE=webhook` and `TROGON_SOURCE_DISCORD_PUBLIC_KEY` |
49+
| Discord | `TROGON_SOURCE_DISCORD_BOT_TOKEN` |
5250
| Slack | `TROGON_SOURCE_SLACK_SIGNING_SECRET` |
5351
| Telegram | `TROGON_SOURCE_TELEGRAM_WEBHOOK_SECRET` |
5452
| GitLab | `TROGON_SOURCE_GITLAB_WEBHOOK_SECRET` |
@@ -78,7 +76,6 @@ Per-source optional tuning (with defaults):
7876
Source-specific extras:
7977

8078
- `TROGON_SOURCE_DISCORD_GATEWAY_INTENTS`
81-
- `TROGON_SOURCE_DISCORD_NATS_REQUEST_TIMEOUT_SECS` (default: `2`)
8279
- `TROGON_SOURCE_SLACK_TIMESTAMP_MAX_DRIFT_SECS` (default: `300`)
8380
- `TROGON_SOURCE_LINEAR_TIMESTAMP_TOLERANCE_SECS` (default: `60`, `0` disables tolerance)
8481

@@ -102,10 +99,7 @@ url = "localhost:4222"
10299
webhook_secret = "gh-secret"
103100

104101
[sources.discord]
105-
mode = "webhook"
106-
public_key = "<discord-public-key-hex>"
107-
# mode = "gateway"
108-
# bot_token = "<discord-bot-token>"
102+
bot_token = "<discord-bot-token>"
109103

110104
[sources.slack]
111105
signing_secret = "slack-secret"

0 commit comments

Comments
 (0)