[SSE] close pubsub subscriber on sse completion (#769)

This commit is contained in:
Johannes Batzill 2023-11-06 18:16:24 +00:00 committed by Harness
parent e731c0fdff
commit 4e0444bba8

View File

@ -96,11 +96,11 @@ func (e *pubsubStreamer) Stream(
namespaceOption := pubsub.WithChannelNamespace(e.namespace) namespaceOption := pubsub.WithChannelNamespace(e.namespace)
topic := getSpaceTopic(spaceID) topic := getSpaceTopic(spaceID)
consumer := e.pubsub.Subscribe(ctx, topic, g, namespaceOption) consumer := e.pubsub.Subscribe(ctx, topic, g, namespaceOption)
unsubscribeFN := func(ctx context.Context) error { cleanupFN := func(ctx context.Context) error {
return consumer.Unsubscribe(ctx, topic) return consumer.Close()
} }
return chEvent, chErr, unsubscribeFN return chEvent, chErr, cleanupFN
} }
// getSpaceTopic creates the namespace name which will be `spaces:<id>`. // getSpaceTopic creates the namespace name which will be `spaces:<id>`.