debasishg / scala-redis

A scala library for connecting to a redis server, or a cluster of redis nodes using consistent hashing on the client side.
1.02k stars 219 forks source link

PubSub: exception processing is difficult to recover from #174

Open skandragon opened 7 years ago

skandragon commented 7 years ago

When a message of type E is passed back in the callback, it's not clear what the application should do. Ideally, attempting to reconnect at some time interval with or without exponential backoff would be nice to have automatically occur, but doing this at the application level seems wrong somehow. It's also pretty difficult from what I can tell.

What is the right thing to do when a message indicating an exception occurred on the redis client is received?

debasishg commented 7 years ago

Currently E is used to handle exceptions that may occur and handle it at https://github.com/debasishg/scala-redis/blob/master/src/main/scala/com/redis/PubSub.scala#L60. The most trivial way to handle it is to initiate a new consumer discarding the current one. You can disconnect using r.disconnect and create a new connection.