{"id":15345680,"url":"https://github.com/git-hulk/go-elect","last_synced_at":"2025-04-05T06:23:16.928Z","repository":{"id":224914924,"uuid":"726057194","full_name":"git-hulk/go-elect","owner":"git-hulk","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-10T09:26:49.000Z","size":58,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T14:12:25.434Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/git-hulk.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":"2023-12-01T12:52:15.000Z","updated_at":"2024-04-14T10:31:17.000Z","dependencies_parsed_at":"2024-03-10T09:37:21.887Z","dependency_job_id":"179a7110-613f-42eb-aaad-253d27c4a345","html_url":"https://github.com/git-hulk/go-elect","commit_stats":null,"previous_names":["git-hulk/go-elect"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/git-hulk%2Fgo-elect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/git-hulk%2Fgo-elect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/git-hulk%2Fgo-elect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/git-hulk%2Fgo-elect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/git-hulk","download_url":"https://codeload.github.com/git-hulk/go-elect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247296206,"owners_count":20915595,"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":[],"created_at":"2024-10-01T11:14:42.761Z","updated_at":"2025-04-05T06:23:16.908Z","avatar_url":"https://github.com/git-hulk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## go-elect\n\ngo-elect is a library for making the election process easier. It provides a simple interface for managing your distributed exclusive job execution,\nand it supports multiple backends for storing the election state:\n\n- [x] [Redis](https://redis.io/)\n- [ ] [Etcd](https://etcd.io/)\n- [ ] [Zookeeper](https://zookeeper.apache.org/)\n- [ ] [MySQL](https://www.mysql.com/)\n- [ ] [PostgreSQL](https://www.postgresql.org/)\n\nAnd more to come...\n\n## How to use\n\n### Redis\n\n```go\npackage main\n\nimport (\n    \"github.com/redis/go-redis/v9\"\n    \"github.com/git-hulk/go-elect/elector/engine/store\"\n    \"github.com/git-hulk/go-elect/elector\"\n)\n\ntype CountRunner struct {\n    count atomic.Int32\n}\n\nfunc (r *CountRunner) Run(_ context.Context) error {\n    r.count.Inc()\n    time.Sleep(100 * time.Millisecond)\n    return nil\n}\n\nfunc main() {\n    ctx := context.Background()\n    redisClient := redis.NewClient(\u0026redis.Options{Addr: \"localhost:6379\"})\n    redisStore := store.NewRedisStore(redisClient)\n\t\n    elector, err := elector.New(redisStore, \"test-elector1-key\", 3 * time.Second,  \u0026CountRunner{})\n    if err := elector.Run(ctx);  err != nil {\n        // handle error\n    }\n    elector.Wait()\n    // use elector.Release() to release the election\n}\n```\n\n## License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgit-hulk%2Fgo-elect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgit-hulk%2Fgo-elect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgit-hulk%2Fgo-elect/lists"}