Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor elector somewhat + test suite + poll-only mode
Here, do a little refactoring in the elector. The overall code doesn't change that much, but we try to tighten things up with little things like improved logging and real exponential backoff. It becomes a start/stop service so that it's a little more normalized with other code and more robust on start/stop. The major improvement is the addition of a test suite. Although there was a nominal suite before that was added during the driver refactor to test the `attemptElectOrReelect` function, the elector was only tested indirectly otherwise through the client. The change comes with a variety of tests that exercise the elector's various behaviors, including one that pits multiple competing electors against each other to make sure that works. Lastly, the elector gains a "poll only" mode in which we check that it can still function using polling only in case a listener isn't available. This doesn't have any effect on River feature-wise yet, but the idea is that after we've added a similar capability to the producer, we'll be able to support systems where `LISTEN`/`NOTIFY` aren't available like PgBouncer in transaction mode, or possibly even MySQL or SQLite in the future. We send the poll only mode through the same barrage of tests that we require it to pass when using a database pool.
- Loading branch information