1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-08-31 21:08:14 +02:00

transport: move key and namespace into redis_pubsub as it is redis specific.

This commit is contained in:
Henrik Hautakoski 2023-01-19 19:07:35 +01:00
parent e0bf53496a
commit af0a4d2714
8 changed files with 55 additions and 43 deletions

View file

@ -11,17 +11,19 @@ import (
type RedisPubsub struct {
pipeline redis.Pipeliner
ctx context.Context
ns Namespace
}
func New(client *redis.Client) *RedisPubsub {
func New(client *redis.Client, ns Namespace) *RedisPubsub {
return &RedisPubsub{
pipeline: client.Pipeline(),
ctx: client.Context(),
ns: ns,
}
}
func (r *RedisPubsub) Publish(channel transport.ChannelInterface, payload []byte) error {
return r.pipeline.Publish(r.ctx, channel.String(), payload).Err()
return r.pipeline.Publish(r.ctx, r.ns.NewKey(channel).String(), payload).Err()
}
func (r *RedisPubsub) Flush() error {