mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-25 17:14:57 +02:00
fix(relay): switch from pub/sub SSE to LPUSH/RPOP list queue (#2581)
* fix(relay): switch from pub/sub SSE to LPUSH/RPOP list queue
The Upstash REST pub/sub subscribe endpoint returns SSE in a format
that is difficult to verify without live debugging (comma-separated
vs JSON, streaming vs immediate-close). Switch to a list-based queue:
- Publishers: PUBLISH /wm:events:notify -> LPUSH /wm:events:queue
- Relay: SSE subscribe loop -> 1s-interval RPOP poll
Benefits: well-defined JSON response {result: '<msg>'|null}, messages
survive relay restarts (not lost if relay is down), no SSE format
ambiguity, simpler code.
* fix(relay): add missing User-Agent headers to LPUSH calls in notify and slack callback
This commit is contained in:
@@ -77,8 +77,8 @@ export default async function handler(req: Request): Promise<Response> {
|
||||
});
|
||||
|
||||
const res = await fetch(
|
||||
`${upstashUrl}/publish/wm:events:notify/${encodeURIComponent(msg)}`,
|
||||
{ method: 'POST', headers: { Authorization: `Bearer ${upstashToken}` } },
|
||||
`${upstashUrl}/lpush/wm:events:queue/${encodeURIComponent(msg)}`,
|
||||
{ method: 'POST', headers: { Authorization: `Bearer ${upstashToken}`, 'User-Agent': 'worldmonitor-edge/1.0' } },
|
||||
);
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
Reference in New Issue
Block a user