The lists:member/2 function will return either true or false. Hence, if it does not return false, it MUST be true that is returned. It is bad style to catch-all this in general when the enumeration is bounded. Further extensions to the enumeration will, rather than fail, return something. Which can be something unwanted.
The three methods from lists: keydelete/3, keysearch/3 and foreach/2 are only referenced once in the file. By making them explicit, we simplify the readability of the code. Furthermore, this change makes the style in the file consistent. Several places prefixed calls explicitly with the lists module, while others did not. Change member/2 and foldl/3 from lists to explicit naming. This marks the complete removal of all -import() statements in the code.
We only have two references to the error logger modules format function in all of the code. By making the error_logger explicit, we help the reader of the module to understand what is going on, rather than split his knowledge and kill his reader-locality.
…ng the joining procedure.
… the safe_loop to be called later when a new leader is elected." This reverts commit a39a432.
…e_loop to be called later when a new leader is elected. Before this patch, any message received in the safe_loop that is not related to the leader election, makes the gen_leader process crash with a 'unmatched case clause' exception. So we now queue these messages, and handle them when the leader election process is concluded.
…ious one is down. Since the handle_DOWN callback is only called in the leader, when the leader goes down, that callback is never called. So the way to solve this is to keep track of the previous leader so that when a new one is elected, the handke_DOWN callback can be called if the previous leader is still down.
The candidates expect to receive the list of worker nodes along with the 'ldr' message. Since it wasn't being sent, they crashed with a "unmatched case clause" exception when a new leader was elected.