• Shaya Potter's avatar
    redo/tweak transfer leader in libraft (#61) · 63b0b1c1
    Shaya Potter authored
    this started off as a small tweak and grew a bit
    
    1) new callback for transfer leader result, along with its own enum of states
    
    2) change/remove raft_reset_transfer_leader() calls
    
    only call in places where there's a new leader or timeout (i.e. failed to transfer within period).
    
    so, we only reset in 3 places 1) recv_appendentries 2) raft_periodic (timeout) 3) raft_become_leader
    
    2a) raft_become_leader also got refactored a little to only issue the normal cb.notify_state_event() callback after it has set its state to be leader (as before, it could fail after the callback was issued)
    
    2b) in raft_periodic the raft_reset_transfer_leader() is pulled out the "if LEADER" block, as will lose leader when a vote is issued to it, we still want it to timeout if leadership isn't gained
    
    3) raft_reset_transfer_leader() does the logic for determining success/failure now, but becaue timeout is its own result which can't be determined by just looking at leader/d...
    63b0b1c1
raft_server.c 52.9 KB