The logic of taking message from message queue was messy. For example,
the leader and follower need to filter and process certain messages in
getMessage method, and so does FastLeaderElection. This results in
duplicate code and makes the intention of the code unclear(code needs to
deal with different kinds of messages just in one method). Refactoring
the code so that we have different kinds of message filters and each
filter filters and processes certain types of messages. This makes the
logic clearer and code reuse better.
The logic of taking message from message queue was messy. For example, the leader and follower need to filter and process certain messages in getMessage method, and so does FastLeaderElection. This results in duplicate code and makes the intention of the code unclear(code needs to deal with different kinds of messages just in one method). Refactoring the code so that we have different kinds of message filters and each filter filters and processes certain types of messages. This makes the logic clearer and code reuse better.