{"id":18010927,"url":"https://github.com/tomtaylor/multibully","last_synced_at":"2025-08-13T15:43:05.830Z","repository":{"id":66430080,"uuid":"118364870","full_name":"tomtaylor/multibully","owner":"tomtaylor","description":"Go library for distributed leader election on a multicast network (like a LAN)","archived":false,"fork":false,"pushed_at":"2018-01-21T19:24:14.000Z","size":7,"stargazers_count":5,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T23:33:58.357Z","etag":null,"topics":["bully","bully-algorithm","lan","leader-election","multicast"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomtaylor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-21T19:08:20.000Z","updated_at":"2024-10-25T06:50:06.000Z","dependencies_parsed_at":"2023-02-22T09:30:47.220Z","dependency_job_id":null,"html_url":"https://github.com/tomtaylor/multibully","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomtaylor%2Fmultibully","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomtaylor%2Fmultibully/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomtaylor%2Fmultibully/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomtaylor%2Fmultibully/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomtaylor","download_url":"https://codeload.github.com/tomtaylor/multibully/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245670924,"owners_count":20653453,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bully","bully-algorithm","lan","leader-election","multicast"],"created_at":"2024-10-30T02:15:50.131Z","updated_at":"2025-03-26T14:32:19.533Z","avatar_url":"https://github.com/tomtaylor.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MultiBully\n\nMultiBully is a Go library for distributed leadership election on a UDP multicast enabled network, like a LAN. It uses the [Bully algorithm](https://en.wikipedia.org/wiki/Bully_algorithm), a relatively simply mechanism which may not be suitable for a large numbers of nodes.\n\nI think there are some bugs and inefficiencies in my implementation of it. It always manages to converge on the correct leader, but it sometimes takes a few goes round. Please feel free to help!\n\n## Usage\n\nThe Bully algorithm elects the node with the largest `pid` to be leader. The `pid` doesn't necessarily need to be the process ID in the operating system – you could choose for this to be a timestamp or a fixed integer for each node. In this implementation, the combination of `pid` and IP address must be unique, so you can run multiple instances on a single host.\n\nWhile MultiBully uses multicast UDP for communication between nodes, it transmits the non-multicast IP of each node in the communication packet, so you can point the follower at the new leader.\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"github.com/tomtaylor/multibully\"\n\t\"log\"\n\t\"os\"\n\t\"net\"\n)\n\nfunc main() {\n\taddress := \"224.0.0.0:9999\"\n\tiface := \"en0\"\n\tstop := make(chan struct{})\n\tpid := uint64(os.Getpid())\n\n\tp, err := multibully.NewParticipant(address, iface, pid, func(state int, ip *net.IP) {\n\t\tswitch state {\n\t\tcase multibully.Follower:\n\t\t\tlog.Println(\"* Became Follower of\", ip)\n\t\tcase multibully.Leader:\n\t\t\tlog.Println(\"* Became Leader\")\n\t\t}\n\t})\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tgo p.StartElection()\n\tp.RunLoop(stop)\n}\n```\n\n## Thanks\n\nThanks to [`oaStuff`](https://github.com/oaStuff/leaderElection) for their sample code which helped me understand how to implement the Bully algorithm.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomtaylor%2Fmultibully","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomtaylor%2Fmultibully","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomtaylor%2Fmultibully/lists"}