florinpatrascu / bolt_sips

Neo4j driver for Elixir
Apache License 2.0
256 stars 49 forks source link

Feature request: auto reconnect #97

Closed ebanisadr closed 3 years ago

ebanisadr commented 3 years ago

Environment

Current behavior

If the neo4j server is restarted while my application is running then all future queries fail with a message like Port #Port<0.100> is closed

Expected behavior

If the connection is closed Bolt.Sips attempts to reopen the connection with the same credentials before returning an error.

florinpatrascu commented 3 years ago

Thank you for your feedback. I was contemplating the proposed feature, and I don't believe it is a responsibility this driver should bear. Even if we'll retry to reconnect, what happens to the service layers depending on it, and to your functions making calls to the db server and failing, during that process? Your app should handle the occasional unavailability of a persistence layer - this is just my opinion. And you can easily achieve the latter through your app design, i.e. monitoring the readiness of your resources, starting and restarting the drivers when the resources are not ready or failing, and so on. @keathley, who's advices I always respect and follow, has a very good series of articles written about this topic (but not limited to designing and configuring Elixir app). You could start with this one: Building Resilient Systems with Stacking Theory - HTH