fix(poller): add 64MB cap on DEVICE_EVENTS NATS stream

Without a byte limit, the stream grows unbounded within its 24h
max_age window. At 101 devices polling every 60s, it hits 128MB
in ~10 hours and OOMs the NATS container.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jason Staack
2026-03-18 05:52:09 -05:00
parent 556545cf9c
commit 05e5595c2b

View File

@@ -141,6 +141,8 @@ func NewPublisher(natsURL string) (*Publisher, error) {
"audit.session.end.>",
},
MaxAge: 24 * time.Hour,
MaxBytes: 64 * 1024 * 1024, // 64MB cap — discard oldest when full
Discard: jetstream.DiscardOld,
})
if err != nil {
nc.Close()