Skip to content

kafaichoi/simple_complete_network_leader_election

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scnle

A Simple Implementation of Leader Election

Leader Selection is important for distributed system. It's incredibly useful for case like ensuring state consistency.

In this simple algorithm, we will assume all nodes are connected and know each others which means it's a complete network.

Right now, the node id is based on the node atom which means that adding new node will always cause new election as its id is always the greatest.

Example

$iex --name [email protected] -S mix

$iex --name [email protected] -S mix

$iex --name [email protected] -S mix

# and then you can see reelection after kill application of the current leader by exiting iex

Test

# might take a bit time(20s in my 2015 macbook) as one of the test is spawning 20 node in local cluster
mix test

Development

# Run Credo
$mix credo

# Run Dialyzer
$mix dialyzer

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages