mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-11-10 14:44:04 +08:00
The cluster package now does the thing the seam described. Nothing constructs it: the server still holds no cluster, and cmd still refuses to start with the options set, so this is inert like the pieces before it. A publish marshals once and drops the line into one bounded queue per peer. A worker batches what it finds, up to the batch linger and flushed early at 100 messages or 256KB, and POSTs NDJSON to that peer's /v1/cluster/message. Fire and forget: a wedged peer backs up only its own queue, and a full queue drops rather than blocking the caller. Inbound batches are authenticated by shared secret, carry an origin header for loop prevention, and are decoded line by line into the server's delivery callback. The heartbeat loop refreshes this node's registry row, reads the live set back and reconciles the per-peer queues, so a departing peer's queue is retired and a new one is reachable on the next publish. Members reports this node plus its peers, with peer health being the freshness of this node's own registry view (registry.Fresh, added here), because an isolated node answering from a frozen view must not be mistaken for current membership. A node that lost the database while a peer is still healthy calls back to close its subscribers, and keeps them when no peer is healthy, since that is an outage rather than isolation. Delivery gaps are not here: a failed batch is logged and counted. They come with the recovery mechanism that uses them.