Skip to content
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

Add support for starting without requiring redis server being available #44

Open
loxs opened this issue Jul 25, 2013 · 4 comments
Open

Comments

@loxs
Copy link
Contributor

loxs commented Jul 25, 2013

I have a slightly larger application. Redis (and eredis) are in no way essential for its functionality. Only "good to have sometimes".

If I shut down redis after starting my application, I'm totally fine now. Eredis (via poolboy) gets reconnected when and if redis comes back up.

But I can't seem to be able to start my applications without having redis up. Poolboy/eredis crashes and brings down my app that spawns it. I could flag that pool as transient, but that means it will never start again if redis becomes available.

So, do you think it's a good idea modify eredis in a way that it's able to start, and connect to redis later if at all?

I am willing to do the required changes myself, if there is a will for them being accepted, and after we have an understanding what to change exactly.

So what do you guys think?

@ransomr
Copy link
Contributor

ransomr commented Jul 29, 2013

I had a similar problem a while ago, although I'm not using poolboy. I think the main issue is that eredis has inconsistent default reconnect behavior. On the initial connection it won't retry, but after a dropped connection it will. Because the initial connection happens during the gen_server init callback, which is synchronous, it can't reconnect.

Ideally the initial connect should be moved out of the init callback, but doing that could theoretically cause issues for existing clients. So what I did instead was add the ability to specify that eredis should not reconnect automatically in any case (using no_reconnect as the reconnect timeout).

In my usage I have a process wrapping the eredis client that handles the reconnect. That makes the initial connect consistent with subsequent reconnects. Also avoids the reconnect process in eredis, which is not supervised or linked.

It would be good to have more robust code in eredis itself if you are up for making the changes. I'd like to see the following:

  1. no connection made synchronously in init, instead connect process is used for all connections
  2. connect process is linked and restarted if it fails
  3. optional callback that will be called when the connection state changes

@knutin
Copy link
Collaborator

knutin commented Jul 29, 2013

I'm up for accepting (and reviewing) such a patch. The behaviour needs to be configurable: crash on start if Redis unavailable or start, but try to reconnect (taking into account no_reconnect).

@radekg
Copy link

radekg commented Aug 8, 2014

Someone already had this covered, partially: https://github.com/layerhq/eredis/commit/cbcb729ecd9f4b17b7e2b3c68d08a852fa7dd358

@zuiderkwast
Copy link

Fixed by #105. Please close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants