{"id":47080263,"url":"https://github.com/danl5/goelect","last_synced_at":"2026-03-12T06:53:06.015Z","repository":{"id":221110660,"uuid":"742833394","full_name":"danl5/goelect","owner":"danl5","description":"Goelect is an open-source, self-contained Golang library designed to facilitate leader election within a distributed system.","archived":false,"fork":false,"pushed_at":"2024-07-13T05:33:34.000Z","size":120,"stargazers_count":217,"open_issues_count":1,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-07-13T06:38:27.194Z","etag":null,"topics":["elect","election","golang","non-depen","self-contained"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danl5.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-01-13T14:05:21.000Z","updated_at":"2024-07-13T05:32:28.000Z","dependencies_parsed_at":"2024-04-18T15:23:18.123Z","dependency_job_id":"2027f026-92f0-4fe8-925d-7a35ddcfd623","html_url":"https://github.com/danl5/goelect","commit_stats":null,"previous_names":["danli001/goelect","danl5/goelect"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/danl5/goelect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danl5%2Fgoelect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danl5%2Fgoelect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danl5%2Fgoelect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danl5%2Fgoelect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danl5","download_url":"https://codeload.github.com/danl5/goelect/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danl5%2Fgoelect/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30417676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T06:40:58.731Z","status":"ssl_error","status_checked_at":"2026-03-12T06:40:40.296Z","response_time":114,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["elect","election","golang","non-depen","self-contained"],"created_at":"2026-03-12T06:53:05.488Z","updated_at":"2026-03-12T06:53:06.003Z","avatar_url":"https://github.com/danl5.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\" style=\"border-bottom: none\"\u003e\n    \u003ca\u003e\u003cimg alt=\"goelect\" src=\"/docs/goelect-logo.svg\"\u003e\u003c/a\u003e\n\u003c/h1\u003e\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/danl5/goelect)](https://goreportcard.com/report/github.com/danl5/goelect) ![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/danl5/goelect?sort=semver)\n\nGoelect is an open-source Go (Golang) library for leader election. It is heavily influenced by the election component of the Raft implementation. For more details, you can refer to [Raft Wiki](https://en.wikipedia.org/wiki/Raft_(algorithm)).\n\n## Features\n* **Independent Operation**: No third-party services are required. You don't need to set up or rely on external systems like ZooKeeper or etcd.\n* **Simplified Integration**: Easy to integrate into your existing Golang projects with minimal configuration.\n* **Supports Novote role**：The no-vote node does not participate in the election.\n* **Highly Available**: Built to be fault-tolerant, suitable for systems that require high availability.\n\n## How to use\n### Config\n```go\n// ElectConfig is a struct that represents the configuration for an election.\ntype ElectConfig struct {\n    // Timeout for heartbeat messages, in milliseconds\n    HeartBeatInterval uint\n    // Timeout for election messages, in milliseconds\n    ElectTimeout uint\n    // Timeout for connecting to peers, in seconds\n    ConnectTimeout uint\n    // List of peers in the network\n    Peers []Node\n    // Node represents the information of this node\n    Node Node\n    // State callbacks\n    CallBacks *StateCallBacks\n    // Timeout for callbacks, in seconds\n    CallBackTimeout int\n}\n```\n### Example\n`examples/onenode/node.go` is a great example of using this goelect package. \n\nCreate an Elect instance:\n```go\n // use the built-in RPC as the transport layer. \n rpcTransport, err := rpc.NewRPC(logger)\n if err != nil {\n  return nil, err\n }\n e, err := goelect.NewElect(\n    rpcTransport,\n    // rpc transport config\n    \u0026rpc.Config{},\n    \u0026goelect.ElectConfig{\n        ElectTimeout:      200,\n        HeartBeatInterval: 150,\n        ConnectTimeout:    10,\n        Peers:             peerNodes,\n        // state transition callbacks\n        CallBacks: \u0026goelect.StateCallBacks{\n            EnterLeader:    enterLeader,\n            LeaveLeader:    leaveLeader,\n            EnterFollower:  enterFollower,\n            LeaveFollower:  leaveFollower, \n            EnterCandidate: enterCandidate,\n            LeaveCandidate: leaveCandidate,\n        },\n        // self node\n        Node: goelect.Node{\n            Address: *nodeAddress,\n            ID:      *nodeAddress,\n        },\n    }, logger)\n```\nStart the Elect:\n```go\nerr = e.Run()\n```\nThis is everything we need to do :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanl5%2Fgoelect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanl5%2Fgoelect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanl5%2Fgoelect/lists"}