From 002a03841344fb5d8fe762f4a57301f0ce88d0d2 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Tue, 10 Sep 2024 08:45:22 +0300 Subject: [PATCH] fixup redis broker Signed-off-by: Vasiliy Tolstov --- redis.go | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/redis.go b/redis.go index 59fd37b..b7767d4 100644 --- a/redis.go +++ b/redis.go @@ -244,28 +244,24 @@ func (b *Broker) Subscribe(ctx context.Context, topic string, handler broker.Han func (b *Broker) configure() error { redisOptions := DefaultOptions - if b.cli != nil && b.opts.Context == nil { - return nil + if b.opts.Context != nil { + if c, ok := b.opts.Context.Value(configKey{}).(*redis.UniversalOptions); ok && c != nil { + redisOptions = c + } } - if b.opts.Context != nil { - if c, ok := b.opts.Context.Value(configKey{}).(*redis.UniversalOptions); ok { - redisOptions = c - if b.opts.TLSConfig != nil { - redisOptions.TLSConfig = b.opts.TLSConfig - } - } + if len(b.opts.Addrs) > 0 { + redisOptions.Addrs = b.opts.Addrs + } + + if b.opts.TLSConfig != nil { + redisOptions.TLSConfig = b.opts.TLSConfig } if redisOptions == nil && b.cli != nil { return nil } - if redisOptions == nil { - redisOptions.Addrs = b.opts.Addrs - redisOptions.TLSConfig = b.opts.TLSConfig - } - c := redis.NewUniversalClient(redisOptions) setTracing(c, b.opts.Tracer)