Skip to content

Commit

Permalink
chore(pubsub): Use a prefix for pubsub topics
Browse files Browse the repository at this point in the history
  • Loading branch information
tarampampam committed Nov 19, 2024
1 parent b813138 commit 0b2b54a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/pubsub/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ var ( // ensure interface implementation
_ Subscriber[any] = (*Redis[any])(nil)
)

const redisTopicPrefix = "webhook-tester-v2:pubsub:"

func NewRedis[T any](c redisClient, encDec encoding.EncoderDecoder) *Redis[T] {
return &Redis[T]{client: c, encDec: encDec}
}

func (ps *Redis[T]) Subscribe(ctx context.Context, topic string) (_ <-chan T, unsubscribe func(), _ error) {
var (
pubSub = ps.client.Subscribe(ctx, topic)
pubSub = ps.client.Subscribe(ctx, redisTopicPrefix+topic)
sub = make(chan T)
stop, stopped = make(chan struct{}), make(chan struct{})
)
Expand Down Expand Up @@ -87,5 +89,5 @@ func (ps *Redis[T]) Publish(ctx context.Context, topic string, event T) error {
return mErr
}

return ps.client.Publish(ctx, topic, data).Err()
return ps.client.Publish(ctx, redisTopicPrefix+topic, data).Err()
}

0 comments on commit 0b2b54a

Please sign in to comment.