3 Commits

Author SHA1 Message Date
dbbdd81a57 fixup redis broker
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-10 09:30:46 +03:00
c7b6158602 fixup redis broker
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-10 09:17:59 +03:00
35b4ea057c fixup redis broker
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-09-10 09:08:01 +03:00

View File

@@ -35,9 +35,9 @@ var (
// Event is an broker.Event
type Event struct {
ctx context.Context
topic string
msg *broker.Message
err error
msg *broker.Message
topic string
}
// Topic returns the topic this Event applies to.
@@ -106,6 +106,8 @@ func (s *Subscriber) loop() {
}
err := s.opts.Codec.Unmarshal([]byte(msg.Payload), p.msg)
p.ctx = metadata.NewIncomingContext(s.ctx, p.msg.Header)
if err != nil {
p.msg.Body = codec.RawMessage(msg.Payload)
if eh != nil {
@@ -223,6 +225,7 @@ func (b *Broker) BatchSubscribe(ctx context.Context, topic string, handler broke
// Subscribe returns a broker.Subscriber for the topic and handler
func (b *Broker) Subscribe(ctx context.Context, topic string, handler broker.Handler, opts ...broker.SubscribeOption) (broker.Subscriber, error) {
s := &Subscriber{
ctx: ctx,
topic: topic,
handle: handler,
opts: b.opts,
@@ -264,6 +267,7 @@ func (b *Broker) configure() error {
c := redis.NewUniversalClient(redisOptions)
setTracing(c, b.opts.Tracer)
b.cli = c
b.statsMeter()
return nil
@@ -275,6 +279,7 @@ func (b *Broker) Connect(ctx context.Context) error {
err = b.cli.Ping(ctx).Err()
}
setSpanError(ctx, err)
b.done = make(chan struct{})
return err
}
@@ -313,5 +318,5 @@ func (b *Broker) Disconnect(ctx context.Context) error {
}
func NewBroker(opts ...broker.Option) *Broker {
return &Broker{done: make(chan struct{}), opts: broker.NewOptions(opts...)}
return &Broker{opts: broker.NewOptions(opts...)}
}