So i'm trying to implement a go routine that simply listens on a Redis subscription (I use the Go-redis library for this) and then sends messages on a channel after it recieves/processes the redis messages.
Something like this:
func foo(redis *redis.Client, comm chan HandlerSignal) {
...
for {
msg, err := pubsub.ReceiveMessage()
sig := HandlerSignal{msg}
comm <- sig
}
}
But I can't figure out the best way to tell the go routine to return when it is blocking and waiting for a redis message.
Does anyone know the common practice for this kind of situation or am I going about this all wrong?