-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Poll only mode for environments without listen/notify (#281)
Here, add a new River client option in `Config.PollOnly` which causes it to start in "poll only" mode where a notifier isn't initialized, and no `LISTEN` statements are issued. This has the downside of events like a leadership resignation or a new job being available not noticed as quickly, but the advantage of making River operable on systems where listen/notify aren't supported, like PgBouncer in transaction mode, or maybe even eventually MySQL or SQLite. A slightly unrelated change that I also made here was to give the elector a more traditional `Config` struct (like other services take) that encompasses more of its configuration instead of raw constructor parameters. I thought I needed to do this originally to better expose a custom elect interval for the client's `PollOnly` test, but it turned out that my slow test was actually due to a different problem and the extra configuration wasn't actually necessary. It seemed to me to clean things up somewhat though, so I left the refactor in. I also remove the listen retry loop on client start up found in the elector and producer. These are probably a bad idea because they may hide a real database problem as they enter their retry loops, and cause the client to require a very lengthy amount of time for its `Start` to fail because of the built-in sleep backoffs. But we'd added them over concerns that the notifier's previous implementation (prior to #253) of discarding all listen/notify problems may have papered over errors that would've otherwise been returned for people trying to use a River client against say a PgBouncer operating in transaction pooling mode. So instead, we now fail fast if there's a problem with listen/notify in their database, and for those wanting to use PgBouncer in transaction pooling mode, we can now recommend using the much cleaner approach of activating `PollOnly` instead. Users can implement their own retry loop on client `Start` if they'd like to protect against intermittent problems on listen/notify start up, but personally I wouldn't expect this to ever be desirable. (The alternative is to allow the program to fail fast and have its supervisor resurrect it, like most programs would do for any other start up hiccup.) The program will already fail fast under most circumstances due to the `SELECT` it performs on start.
- Loading branch information
Showing
7 changed files
with
209 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.