You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to know when db connection goes down and gets up at application level. So, I can put my app in emergency mode. For example, if db connection is not available for 5 mins, I could close the app (process.exit) or rely on app caches only and return some additional information for my API clients in response.
Proposed implementation
I propose to add 2 callback functions onconnected and ondisconnected (maybe there is a better way to express this through a single function, like connectionStateChanged but then it will require to call this function when connection becomes idle, so not sure)
The text was updated successfully, but these errors were encountered:
stalniy
changed the title
handling of db socket disconnected/connected events
Expose db socket disconnected/connected events
Mar 5, 2021
I think the interesting part here is knowing if all connections are down, but only if the reason was something other than idle_timeout.
So perhaps if the last connection is closed for any other reason than idle_timeout a disconnected event is raised. Would that be suitable for your use case too?
Now perhaps a low level option of listening to every single connection as well could be interesting, but imo not as important.
Motivation
I'd like to know when db connection goes down and gets up at application level. So, I can put my app in emergency mode. For example, if db connection is not available for 5 mins, I could close the app (
process.exit
) or rely on app caches only and return some additional information for my API clients in response.Proposed implementation
I propose to add 2 callback functions
onconnected
andondisconnected
(maybe there is a better way to express this through a single function, likeconnectionStateChanged
but then it will require to call this function when connection becomes idle, so not sure)The text was updated successfully, but these errors were encountered: