volunteer :: (RaftLog l e v) => Raft l e v -> IO Bool
volunteer vRaft = do
    participant <- atomically $ do
        raft <- readTVar $ raftContext vRaft
        let name = raftName raft
            cfg = raftStateConfiguration $ raftState raft
        return $ isClusterParticipant name (clusterConfiguration cfg)
    -- this allows us to have raft servers that are up and running,
    -- but they will just patiently wait until they are a participant
    -- before volunteering
    if participant
        then do
            results <- race (doVote vRaft) (doVolunteer vRaft)
            case results of
                Left _ -> return False
                Right won -> return won
        else return False
volunteer :: (RaftLog l e v) => Raft l e v -> IO Bool
volunteer vRaft = do
    participant <- atomically $ do
        raft <- readTVar $ raftContext vRaft
        let name = raftName raft
            cfg = raftStateConfiguration $ raftState raft
        return $ isClusterParticipant name (clusterConfiguration cfg)
    -- this allows us to have raft servers that are up and running,
    -- but they will just patiently wait until they are a participant
    -- before volunteering
    if participant
        then do
            results <- race (doVote vRaft) (doVolunteer vRaft)
            case results of
                Left _ -> return False
                Right won -> return won
        else return False
volunteer vRaft = do
    participant <- atomically $ do
        raft <- readTVar $ raftContext vRaft
        let name = raftName raft
            cfg = raftStateConfiguration $ raftState raft
        return $ isClusterParticipant name (clusterConfiguration cfg)
    -- this allows us to have raft servers that are up and running,
    -- but they will just patiently wait until they are a participant
    -- before volunteering
    if participant
        then do
            results <- race (doVote vRaft) (doVolunteer vRaft)
            case results of
                Left _ -> return False
                Right won -> return won
        else return False