From 930d3a4b7fb235a74a39cb8ff152db00bf0b6dd9 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 14 Oct 2022 12:05:10 +0100 Subject: [PATCH] Set `InactiveThreshold` on roomserver durable consumers --- roomserver/internal/input/input.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/roomserver/internal/input/input.go b/roomserver/internal/input/input.go index c47793f0a..bf0e3532a 100644 --- a/roomserver/internal/input/input.go +++ b/roomserver/internal/input/input.go @@ -130,6 +130,13 @@ func (r *Inputer) startWorkerForRoom(roomID string) { DeliverPolicy: nats.DeliverAllPolicy, FilterSubject: subject, AckWait: MaximumMissingProcessingTime + (time.Second * 10), + + // If the consumer is inactive for a while then we will allow NATS + // to clean it up. This prevents us from holding onto durable + // consumers indefinitely for rooms that might no longer be active, + // since they do have a small overhead. If the room becomes active + // again then we'll recreate the consumer anyway. + InactiveThreshold: time.Hour, }, ); err != nil { logrus.WithError(err).Errorf("Failed to create consumer for room %q", w.roomID)