{"id":15648470,"url":"https://github.com/coryan/gee-h","last_synced_at":"2025-10-11T05:35:38.285Z","repository":{"id":102931509,"uuid":"95664571","full_name":"coryan/gee-h","owner":"coryan","description":"A C++14 client library for etcd leader election","archived":false,"fork":false,"pushed_at":"2018-03-11T17:19:08.000Z","size":276,"stargazers_count":3,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T14:43:19.196Z","etag":null,"topics":["cpp-library","cpp14","etcd","etcdv3","leader-election"],"latest_commit_sha":null,"homepage":null,"language":"C++","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/coryan.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":"2017-06-28T12:01:08.000Z","updated_at":"2019-12-19T09:14:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"c8a757c3-22f8-44aa-8f70-acc69ad248d1","html_url":"https://github.com/coryan/gee-h","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/coryan/gee-h","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryan%2Fgee-h","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryan%2Fgee-h/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryan%2Fgee-h/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryan%2Fgee-h/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coryan","download_url":"https://codeload.github.com/coryan/gee-h/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryan%2Fgee-h/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006350,"owners_count":26084085,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cpp-library","cpp14","etcd","etcdv3","leader-election"],"created_at":"2024-10-03T12:24:57.154Z","updated_at":"2025-10-11T05:35:38.258Z","avatar_url":"https://github.com/coryan.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gee-H\n\nA C++14 client library for leader election using `etcd`.\n\n## Status\n[![Build Status](https://travis-ci.org/coryan/gee-h.svg?branch=master)](https://travis-ci.org/coryan/gee-h)\n[![codecov](https://codecov.io/gh/coryan/gee-h/branch/master/graph/badge.svg)](https://codecov.io/gh/coryan/gee-h)\n\nThis library is work in progress, it correctly handles a leader election against a single etcd server, I am currently\nworking on supporting failovers in the etcd cluster.\n\n## Install\n\nThis library is built using `cmake(1)`.  On Linux and other Unix variants the usual commands to build it are:\n\n```commandline\ncmake .\nmake\nmake test\nmake install\n```\n\n## Motivation\n\n[Leader election](https://en.wikipedia.org/wiki/Leader_election)\nis a building block for large distributed systems.\nThe context is some component of the distributed system that needs to be\nreplicated for increased availability, but that cannot have more\nthan one instance active at a time because the component acts as a coordinator to\ndistribute some non-trivially parallelizable workload.\n\nThe common solution is to perform a leader election between the instances\nof the component in question.\nThe instance that \"wins\" the election plays the leader role and remains active.\nThe other instances passively wait until the leader terminates, gracefully or not.\n\nGee-H solves this coordination problem using the\n[`etcd` lock service](https://en.wikipedia.org/wiki/Container_Linux_by_CoreOS#Cluster_infrastructure).\n\n## Watching an Election\n\nThe `examples/observe_election.cpp` example shows how to watch an election.\nAfter some initialization boilerplate the main class is created using:\n\n```cpp\n  auto channel = grpc::CreateChannel(...);\n  auto queue = std::make_shared\u003cgh::active_completion_queue\u003e();\n  gh::watch_election (queue.cq(), channel, election_name);\n```\n\nthe class monitors the given election (`election_name` in this case).\nThe application can create callbacks to receive updates about the election:\n\n```cpp\nauto subscriber = [](std::string const\u0026 key, std::string const\u0026 value) {\n  if (key.empty()) {\n    std::cout \u003c\u003c \"no current leader\" \u003c\u003c std::endl;\n    return;\n  }\n  std::cout \u003c\u003c \"current leader is \" \u003c\u003c key \u003c\u003c \", with value=\" \u003c\u003c value \u003c\u003c std::endl;\n};\nauto token = election_observer-\u003esubscribe(std::move(subscriber));\n```\n\n## Joining an Election\n\nThe `examples/join_election.cpp` example shows how to join an election.\nAfter some initialization boilerplate the main class is created using:\n\n```cpp\n  auto channel = grpc::CreateChannel(...);\n  auto queue = std::make_shared\u003cgh::active_completion_queue\u003e();\n  gh::leader_election election(queue, channel, \"my-election\", \"my-value\", std::chrono::seconds(5));\n```\n\nThe application can then block until the current candidate wins the election:\n\n```cpp\nauto fut = election.campaign();\nbool elected = fut.get();\n```\n\n## What is that name?\n\n[Gee-H](https://en.wikipedia.org/wiki/Gee-H_(navigation)) was a radio navigation system developed during\nWorld War II.  It has nothing to do with leader election, or C++14, or the `etcd` server.\nI just like short names for namespaces: `gh::` in this case.\n\n\n## LICENSE\n\ngee-h is distributed under the Apache License, Version 2.0.\nThe full licensing terms can be found in the `LICENSE` file.\n\n---\n\n   Copyright 2017 Carlos O'Ryan\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoryan%2Fgee-h","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoryan%2Fgee-h","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoryan%2Fgee-h/lists"}