{"id":18832562,"url":"https://github.com/linka-cloud/leaderelection","last_synced_at":"2026-05-09T15:03:49.316Z","repository":{"id":184821639,"uuid":"670683783","full_name":"linka-cloud/leaderelection","owner":"linka-cloud","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-08T14:39:40.000Z","size":165,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-30T07:20:21.066Z","etag":null,"topics":["cloud-computing","distributed-systems","git","gossip","kubernetes","leader-election","memberlist","s3"],"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/linka-cloud.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}},"created_at":"2023-07-25T15:40:39.000Z","updated_at":"2024-12-24T20:02:34.000Z","dependencies_parsed_at":"2023-07-30T13:26:46.979Z","dependency_job_id":"60668733-0f7e-4bf1-b32e-b834a9cbb834","html_url":"https://github.com/linka-cloud/leaderelection","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"706d37a77c39e7ad85047b1ce695abf14e667e8c"},"previous_names":["linka-cloud/leaderelection"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linka-cloud%2Fleaderelection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linka-cloud%2Fleaderelection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linka-cloud%2Fleaderelection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linka-cloud%2Fleaderelection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linka-cloud","download_url":"https://codeload.github.com/linka-cloud/leaderelection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239768927,"owners_count":19693763,"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":["cloud-computing","distributed-systems","git","gossip","kubernetes","leader-election","memberlist","s3"],"created_at":"2024-11-08T01:58:14.708Z","updated_at":"2026-01-25T17:30:20.152Z","avatar_url":"https://github.com/linka-cloud.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# leaderelection\n\n[![Language: Go](https://img.shields.io/badge/lang-Go-6ad7e5.svg?style=flat-square\u0026logo=go)](https://golang.org/)\n[![Go Reference](https://pkg.go.dev/badge/go.linka.cloud/leaderelection.svg)](https://pkg.go.dev/go.linka.cloud/leaderelection)\n\n**Project status: *alpha***\n\n*The API, spec, status and other user facing objects are subject to change.* \n*We do not support backward-compatibility for the alpha releases.*\n\n## Overview\n\nThis module is extracted from the [k8s.io/client-go](https://github.com/kubernetes/client-go) package. \nIt provides a simple interface for implementing leader election in a distributed system using different backends:\n- [kubernetes](k8s): using [Lease](https://kubernetes.io/docs/concepts/architecture/leases/) \n  (Kubernetes API)\n\n  [![Go Reference](https://pkg.go.dev/badge/go.linka.cloud/leaderelection/k8s.svg)](https://pkg.go.dev/go.linka.cloud/leaderelection/k8s)\n\n- [gossip](gossip): using distributed in memory key-value store (based on [hashicorp/memberlist](https://github.com/hashicorp/memberlist))\n\n  [![Go Reference](https://pkg.go.dev/badge/go.linka.cloud/leaderelection/gossip.svg)](https://pkg.go.dev/go.linka.cloud/leaderelection/gossip)\n\n- [s3](s3): using a simple json file stored in a s3 bucket\n\n  [![Go Reference](https://pkg.go.dev/badge/go.linka.cloud/leaderelection/s3.svg)](https://pkg.go.dev/go.linka.cloud/leaderelection/s3)\n\n- [git](git): using a simple json file stored in a git repository\n  \n  [![Go Reference](https://pkg.go.dev/badge/go.linka.cloud/leaderelection/git.svg)](https://pkg.go.dev/go.linka.cloud/leaderelection/git)\n\n\n## Usage\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"time\"\n    \n    \"k8s.io/apimachinery/pkg/util/rand\"\n    \n    le \"go.linka.cloud/leaderelection\"\n    \"go.linka.cloud/leaderelection/[backend]\"\n)\n\nconst (\n\tlockName = \"test\"\n)\n\nfunc main() {\n\tctx, cancel := context.WithCancel(le.SetupSignalHandler())\n\tdefer cancel()\n\n\t\n\tl, err := [backend].New(ctx, lockName, rand.String(8), ...)\n\tif err != nil {\n\t\tlogrus.Fatal(err)\n\t}\n\tconfig := le.Config{\n\t\tLock:            l,\n\t\tLeaseDuration:   15 * time.Second,\n\t\tRenewDeadline:   10 * time.Second,\n\t\tRetryPeriod:     2 * time.Second,\n\t\tReleaseOnCancel: true,\n\t\tName:            lockName,\n\t\tCallbacks: le.Callbacks{\n\t\t\tOnStartedLeading: func(ctx context.Context) {\n\t\t\t\tlogrus.Info(\"started leading\")\n\t\t\t},\n\t\t\tOnStoppedLeading: func() {\n\t\t\t\tlogrus.Info(\"stopped leading\")\n\t\t\t},\n\t\t\tOnNewLeader: func(identity string) {\n\t\t\t\tlogrus.Infof(\"new leader: %s\", identity)\n\t\t\t},\n\t\t},\n\t}\n\te, err := le.New(config)\n\tif err != nil {\n\t\tlogrus.Fatal(err)\n\t}\n\te.Run(ctx)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinka-cloud%2Fleaderelection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinka-cloud%2Fleaderelection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinka-cloud%2Fleaderelection/lists"}