Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eagerly reconnect in PgListener::try_recv (#3585)
When PgListener's underlying connection is closed, try_recv() will return Ok(None) and reconnect on the next call. In this case, user code is supposed to reload its state from the database (or otherwise handle potentially missing messages). However, if the user code uses another database connection to do so then there is a period between when the state is reloaded and PgListener's connection is re-established where notifications are lost without any indication that this has happened. This commit changes PgListener to eagerly reconnect by default. At the suggestion of @abonander on discord, I have also included an option to switch back to the old behaviour in the case where someone was depending on it. Now, if the connection is closed then, by default, user code can do whatever it needs to do in order to recover and any notifications emitted in the meantime will be waiting for it when it is done.
- Loading branch information