{"id":18821608,"url":"https://github.com/octu0/bully-election","last_synced_at":"2026-01-18T09:30:17.922Z","repository":{"id":259019828,"uuid":"875199296","full_name":"octu0/bully-election","owner":"octu0","description":"memberlist based Bully Leader Election","archived":false,"fork":false,"pushed_at":"2024-10-29T05:09:58.000Z","size":88,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-08T09:12:39.822Z","etag":null,"topics":["bully-algorithm","clustering","leader-election","membership-management"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/octu0/bully-election","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/octu0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-10-19T10:59:50.000Z","updated_at":"2024-11-05T02:33:42.000Z","dependencies_parsed_at":"2024-11-08T00:45:02.870Z","dependency_job_id":"b98d800a-4e0b-4726-9aa9-279fdd0a8ba2","html_url":"https://github.com/octu0/bully-election","commit_stats":null,"previous_names":["octu0/bully-election"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Fbully-election","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Fbully-election/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Fbully-election/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Fbully-election/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/octu0","download_url":"https://codeload.github.com/octu0/bully-election/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239758900,"owners_count":19692041,"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-algorithm","clustering","leader-election","membership-management"],"created_at":"2024-11-08T00:44:53.073Z","updated_at":"2026-01-18T09:30:17.868Z","avatar_url":"https://github.com/octu0.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `bully-election`\n\n[![MIT License](https://img.shields.io/github/license/octu0/bully-election)](https://github.com/octu0/bully-election/blob/master/LICENSE)\n[![GoDoc](https://pkg.go.dev/badge/github.com/octu0/bully-election)](https://pkg.go.dev/github.com/octu0/bully-election)\n[![Go Report Card](https://goreportcard.com/badge/github.com/octu0/bully-election)](https://goreportcard.com/report/github.com/octu0/bully-election)\n[![Releases](https://img.shields.io/github/v/release/octu0/bully-election)](https://github.com/octu0/bully-election/releases)\n\nHashicorp's [memberlist](https://github.com/hashicorp/memberlist) based [Bully Leader Election](https://en.wikipedia.org/wiki/Bully_algorithm).\n\nFeatures:\n- Simple API\n- Voter / Nonvoter node state management(monitoring)\n- TransferLeadership\n\n## Installation\n\n```bash\ngo get github.com/octu0/bully-election\n```\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"time\"\n\n\t\"github.com/hashicorp/memberlist\"\n\t\"github.com/octu0/bully-election\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tconf := memberlist.DefaultLANConfig()\n\tconf.Name = \"node1\"\n\tconf.BindPort = 7947\n\tconf.AdvertiseAddr = \"10.0.0.123\"\n\tconf.AdvertisePort = conf.BindPort\n\n\tb, err := bullyelection.CreateVoter(ctx, conf,\n\t\tWithElectionTimeout(1*time.Second),\n\t\tWithObserveFunc(func(b *bullyelection.Bully, evt bullyelection.NodeEvent, id, addr string) {\n\t\t\tlog.Printf(\"[%s] event: %s node=%s(%s)\", b.ID(), evt.String(), id, addr)\n\t\t\tif evt == bullyelection.ElectionEvent {\n\t\t\tfor _, n := range b.Members() {\n\t\t\t\tlog.Printf(\"%s is_leader=%v\", n.ID(), n.IsLeader())\n\t\t\t}\n\t\t}\n\t\t}),\n\t\tWithOnErrorFunc(func(err error) {\n\t\t\tlog.Printf(\"error=%+v\", err)\n\t\t}),\n\t)\n\terr := b.Join(\"10.0.0.1\")\n\tb.IsLeader()\n\tb.UpdateMetadata([]byte(\"hello world\"))\n\n\tnn, _ := bullyelection.CreateNonVoter(ctx, conf2)\n\terr := nn.Join(\"10.0.0.1\")\n\tfor _, m := range nn.Members() {\n\t\t_ = m.UserMetadata()\n\t}\n\n\tb.Leave()\n}\n```\n\n# License\n\nMIT, see LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctu0%2Fbully-election","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foctu0%2Fbully-election","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctu0%2Fbully-election/lists"}