4

GitHub - Abdulsametileri/leader-election-bully-algorithm: This repository is imp...

 1 year ago
source link: https://github.com/Abdulsametileri/leader-election-bully-algorithm
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Introduction

You can check the article out.

Working Demo

asciicast

Quickstart with Docker

This project has an already configured Docker Compose file launching four nodes.

You can build and run docker-compose as follows:

docker-compose up --build

You can kill some nodes with docker commands to test the cluster behavior.

If you want to add new nodes, please add its address to hardcoded variables.

// nodeAddressByID: It includes nodes currently in cluster
var nodeAddressByID = map[string]string{
	"node-01": "node-01:6001",
	"node-02": "node-02:6002",
	"node-03": "node-03:6003",
	"node-04": "node-04:6004",
}

In this repository, I wanted to avoid implementing a service discovery mechanism. I aim to learn and implement basic how to do leader election without service discovery.

You can also find my service discovery implementation and article

Quickstart without Docker

You can still execute this project without using Docker.

First, change the Node IPs. For example

// nodeAddressByID: It includes nodes currently in cluster
var nodeAddressByID = map[string]string{
	"node-01": "node-01:6001", <--- change here to localhost:6001
	"node-02": "node-02:6002", <--- change here to localhost:6002
	"node-03": "node-03:6003", <--- change here to localhost:6003
	"node-04": "node-04:6004", <--- change here to localhost:6004
}

Second, you can set which node you want to run in Program arguments like

go run . node-02

Additional ToDos

  • 1- Implement with service discovery
  • 2- Change ordered election to dynamic.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK