-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Verk should be able to start even if Redis connection is not available #113
Comments
Yeah, I agree that Verk should be able to start without Redis and keep retrying to reconnect etc. Your solution seems to be the way to go 👍 |
I'm unsure about this one. Given the init callback is about making guarantees about the readiness of the system should we consider Werk ready if it does not have a connected Redis instance? It seems like a fairly fundamental dependancy. |
@lpil I understand your point and perhaps we should just leave it at that. It might help to explain where I hit this issue at first. I have a webserver which has added Verk to its supervision tree but only uses Verk to enqueue tasks to Redis in the Resque/Verk format. There is a separate processor application that is responsible for dequeueing and processing those tasks. While I understand why it makes sense for the processor to crash if it cannot cannot to Redis, I would rather the webserver be able to start and serve traffic while it continues to retry connecting. Maybe the premise is flawed here? It might be non-standard usage of the library and thus it doesn't make sense to build around support for the use case. I am not sure. |
It seems that Verk doesn't require the application to be started in order to enqueue a job. Lines 53 to 59 in d0f07c1
You could just call that function and pass in the pid/atom of your own Redis instance. :) |
@keyan for your specific use case you could pass a connection to
Ok so Verk supports losing connectivity with I'm not sure if this "inconsistency" is bad or good... |
I've been doing some thinking and reading and I think that now I agree with you. Werk can reasonably guarantee that it is in a state where it could accept jobs, though not that it has somewhere to accept them from. :) |
Several GenServers include operations in their
init()
functions that require a connection to Redis, for example:verk/lib/verk/schedule_manager.ex
Lines 31 to 34 in e39293e
verk/lib/verk/queue_manager.ex
Lines 84 to 88 in e39293e
This results in these GenServers failing to start when the Redis connection is not available. The effect is that if an application adds
Verk.Supervisor
to their supervision tree, the application will not be able to start if Redis is not available.This doesn't seem to be what we would want in most cases. Instead I'd expect my application to be able to handle Redis connection retries in case there was a temporary connection disruption during startup.
Possible solution
We could move function calls that rely on the Redis connection to be present out of
init()
and instead do that work in a callback. This would allow for the work to fail and the GenServer to still start.For example
Verk.QueueManager.init
would look something like:The text was updated successfully, but these errors were encountered: