zio-redis
zio-redis copied to clipboard
Asynchronous connection initialization in Layer
Hi!
Today the RedisExecutor seems to connect synchronosly when the layer is constructed, which means that my application is unable to start if Redis is currently unavailable. I think it would be preferable if initializing the connection happened asynchronously (or if the user could choose between the two).
@mijicd I would like to pick this up if no one started working on this?
@drmarjanovic all yours
Hi!
I've investigated this a little bit and I just want to be sure what is the expected behavior.
Currently, we have the following scenarios:
- Redis is unavailable
- Start the example app
- Nothing happens, the application is closed
and
- Redis is available
- Start the example app
- The application is up and running
- Redis becomes unavailable
- The application is still running, but queries are going to fail
So, I'm just wondering, do you want a lazy init? Even if Redis is down, do you still want your application up and running and to start failing when Redis is actually invoked?
@frekw @mijicd
This is the behaviour I would want, which is essentially that of a connection pool (perhaps a job for ZPool?)
- Redis is unavailable
- My application is able to start
- Queries fail
- Redis becomes available
- Queries work
- Redis becomes unavailable
- Queries fail
- etc
But e.g a common scenario would be that when Redis goes down, application load increases. And if I can't spawn new instances of my application when Redis is down I'm unable to auto scale to meet the load :)