Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion router/pkg/pubsub/redis/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"sync"
"time"

"github.com/wundergraph/cosmo/router/pkg/metric"

Expand Down Expand Up @@ -100,10 +101,18 @@ func (p *ProviderAdapter) Subscribe(ctx context.Context, conf datasource.Subscri
msgChan := sub.Channel()

cleanup := func() {
err := sub.PUnsubscribe(ctx, subConf.Channels...)
unsubCtx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()

err := sub.PUnsubscribe(unsubCtx, subConf.Channels...)
if err != nil {
log.Error(fmt.Sprintf("error unsubscribing from redis for topics %v", subConf.Channels), zap.Error(err))
}

err = sub.Close()
if err != nil {
log.Error(fmt.Sprintf("error closing connection to redis: %v", zap.Error(err)))
}
Comment thread
dkorittki marked this conversation as resolved.
}

p.closeWg.Add(1)
Expand Down
Loading