mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
break loop when subscribe count is 0
This commit is contained in:
@@ -40,11 +40,11 @@ func (r *Redis) subscribe(ctx context.Context, consume ConsumeFunc, channel ...s
|
||||
}
|
||||
case redis.Subscription:
|
||||
fmt.Println(msg)
|
||||
//
|
||||
//if msg.Count == 0 {
|
||||
// // all channels are unsubscribed
|
||||
// return
|
||||
//}
|
||||
|
||||
if msg.Count == 0 {
|
||||
// all channels are unsubscribed
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -54,9 +54,9 @@ func (r *Redis) subscribe(ctx context.Context, consume ConsumeFunc, channel ...s
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
if err := psc.Unsubscribe(); err != nil {
|
||||
fmt.Printf("redis pubsub unsubscribe err: %v", err)
|
||||
fmt.Printf("redis pubsub unsubscribe err: %v \n", err)
|
||||
}
|
||||
return nil
|
||||
done <- nil
|
||||
case <-tick.C:
|
||||
//fmt.Printf("ping message \n")
|
||||
if err := psc.Ping(""); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user