psc := redis.PubSubConn{c}
psc.Subscribe("example")
func Receive() {
for {
switch v := psc.Receive().(type) {
case redis.Message:
fmt.Printf("%s: message: %s
", v.Channel, v.Data)
case redis.Subscription:
fmt.Printf("%s: %s %d
", v.Channel, v.Kind, v.Count)
case error:
return v
}
}
}
In the above code(taken from Redigo doc), if connection is lost, all subscriptions are also lost. What will be better way to recover from lost connection and resubscribe.