diff --git a/redis.go b/redis.go index b7767d4..d2b03f8 100644 --- a/redis.go +++ b/redis.go @@ -230,14 +230,13 @@ func (b *Broker) Subscribe(ctx context.Context, topic string, handler broker.Han done: make(chan struct{}), } - // Run the receiver routine. - go s.loop() - s.sub = b.cli.Subscribe(s.ctx, s.topic) if err := s.sub.Ping(ctx, ""); err != nil { return nil, err } + go s.loop() + return s, nil }