canonical / raft

Unmaintained C implementation of the Raft consensus protocol
Other
940 stars 136 forks source link

Add raft_voter_contact() #492

Closed ralight closed 9 months ago

ralight commented 9 months ago

This returns the number of voting nodes that are recently in contact with the leader, to allow determining if the cluster is currently in a degraded / at risk state.

I'd be interested on your thoughts on this. At the moment it feels like not being able to find out this information is an omission.

codecov[bot] commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (d67cffd) 77.13% compared to head (2e103cb) 77.10%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #492 +/- ## ========================================== - Coverage 77.13% 77.10% -0.03% ========================================== Files 52 52 Lines 9839 9847 +8 Branches 2514 2516 +2 ========================================== + Hits 7589 7593 +4 - Misses 1068 1072 +4 Partials 1182 1182 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

cole-miller commented 9 months ago

Not speaking for the rest of the team, but this seems reasonable to me. I would like a note in the docstring that the return value is not to be relied on for correctness (since it could be out of date), and a couple of tests.

ralight commented 9 months ago

@cole-miller Thanks for the feedback. I've added the initialisation to 0 on init, reset to 1 on changing to a leader, and added a test which starts off with 3 nodes, kills off a node, and revives the node, with checks at each step. If you'd like more tests please give me some hints on the direction to go in.