{"id":18279283,"url":"https://github.com/shafreeck/cetcd","last_synced_at":"2025-10-24T06:47:25.508Z","repository":{"id":35236390,"uuid":"39495833","full_name":"shafreeck/cetcd","owner":"shafreeck","description":"Cetcd is a C client library  for etcd with full features support","archived":false,"fork":false,"pushed_at":"2019-12-17T14:45:49.000Z","size":118,"stargazers_count":70,"open_issues_count":11,"forks_count":39,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-06-02T22:01:53.801Z","etag":null,"topics":["c","etcd"],"latest_commit_sha":null,"homepage":"","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/shafreeck.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}},"created_at":"2015-07-22T08:53:13.000Z","updated_at":"2025-02-27T09:40:44.000Z","dependencies_parsed_at":"2022-09-16T15:23:04.597Z","dependency_job_id":null,"html_url":"https://github.com/shafreeck/cetcd","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/shafreeck/cetcd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shafreeck%2Fcetcd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shafreeck%2Fcetcd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shafreeck%2Fcetcd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shafreeck%2Fcetcd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shafreeck","download_url":"https://codeload.github.com/shafreeck/cetcd/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shafreeck%2Fcetcd/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262963254,"owners_count":23391783,"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":["c","etcd"],"created_at":"2024-11-05T12:28:11.848Z","updated_at":"2025-10-24T06:47:20.475Z","avatar_url":"https://github.com/shafreeck.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cetcd is a C client for etcd\n\n[![License](https://img.shields.io/badge/license-Apache2.0-blue.svg)](LICENSE)\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/shafreeck/cetcd?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n[![Stories in Ready](https://badge.waffle.io/shafreeck/cetcd.png?label=ready\u0026title=Ready)](https://waffle.io/shafreeck/cetcd)\n[![wercker status](https://app.wercker.com/status/cc417f5b6e093b4d0b962580a3d022cb/s/master \"wercker status\")](https://app.wercker.com/project/bykey/cc417f5b6e093b4d0b962580a3d022cb)\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*\n\n- [Cetcd is a C client for etcd](#cetcd-is-a-c-client-for-etcd)\n  - [Status](#status)\n  - [Features](#features)\n  - [Deps](#deps)\n  - [Install](#install)\n  - [Link](#link)\n  - [Examples](#examples)\n  - [Usage](#usage)\n    - [Create an array to store the etcd addresses](#create-an-array-to-store-the-etcd-addresses)\n    - [Init the cetcd_client](#init-the-cetcd_client)\n    - [Set a key](#set-a-key)\n    - [Get a key](#get-a-key)\n    - [List a directory](#list-a-directory)\n    - [Clean all resources](#clean-all-resources)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Status\n cetcd is on active development. It aims to be used in production environment and to supply full features of etcd.\n **Any issues or pull requests are welcome!**\n\n## Features\n * Round-robin load balance and failover\n * Full support for etcd keys space apis\n * Multiple concurrent watchers support\n\n## Deps\n cetcd use [sds](https://github.com/antirez/sds) as a dynamic string utility.  It is licensed in sds/LICENSE.\n sds is interaged in cetcd's source code, so you don't have to install it before.\n\n [yajl](https://github.com/lloyd/yajl) is a powerful json stream parsing libaray. We use the stream apis to\n parse response from cetcd. It is already integrated as a third-party dependency, so you are not necessary to\n install it before.\n\n [curl](http://curl.haxx.se/download.html) is required to issue HTTP requests in cetcd\n\n## Install\n\nInstall curl if needed\non Ubuntu\n```\napt-get install libcurl4-openssl-dev\n```\nor on CentOS\n```\nyum install libcurl-devel\n```\nthen\n ```\n make\n make install\n ```\n It default installs to /usr/local.\n\n Use\n ```\n make install prefix=/path\n ```\n to specify your custom path.\n\n## Link\n Use `-lcetcd` to link the library\n\n## Examples\n* [cetcd_get.c](examples/cetcd_get.c)\n* [cetcd_lsdir.c](examples/cetcd_lsdir.c)\n* [multi_watch.c](examples/multi_watch.c)\n\n## Usage\ncetcd_array is an expandable dynamic array. It is used to pass etcd cluster addresses, and return cetcd response nodes\n\n### Create an array to store the etcd addresses\n```\n    cetcd_array addrs;\n\n    cetcd_array_init(\u0026addrs, 3);\n    cetcd_array_append(\u0026addrs, \"127.0.0.1:2379\");\n    cetcd_array_append(\u0026addrs, \"127.0.0.1:2378\");\n    cetcd_array_append(\u0026addrs, \"127.0.0.1:2377\");\n```\n\ncetcd_client is a context cetcd uses to issue requests, you should init it with etcd addresses\n### Init the cetcd_client\n```\n    cetcd_client cli;\n    cetcd_client_init(\u0026cli, \u0026addrs);\n```\n\nThen you can issue an cetcd request which reply with an cetcd response\n### Set a key\n```\n    cetcd_response *resp;\n    resp = cetcd_set(\u0026cli, \"/service/redis\", \"hello cetcd\", 0);\n    if(resp-\u003eerr) {\n        printf(\"error :%d, %s (%s)\\n\", resp-\u003eerr-\u003eecode, resp-\u003eerr-\u003emessage, resp-\u003eerr-\u003ecause);\n    }\n    cetcd_response_release(resp);\n```\n\n### Get a key\n```\n    cetcd_response *resp;\n    resp = cetcd_get(\u0026cli, \"/service/redis\");\n    if(resp-\u003eerr) {\n        printf(\"error :%d, %s (%s)\\n\", resp-\u003eerr-\u003eecode, resp-\u003eerr-\u003emessage, resp-\u003eerr-\u003ecause);\n    }\n    cetcd_response_release(resp);\n```\n### List a directory\n```\n    cetcd_response *resp;\n    resp = cetcd_lsdir(\u0026cli, \"/service\", 1, 1);\n    if(resp-\u003eerr) {\n        printf(\"error :%d, %s (%s)\\n\", resp-\u003eerr-\u003eecode, resp-\u003eerr-\u003emessage, resp-\u003eerr-\u003ecause);\n    }\n    cetcd_response_print(resp);\n    cetcd_response_release(resp);\n```\n\n### Clean all resources\n```\n    cetcd_array_destory(\u0026addrs);\n    cetcd_client_destroy(\u0026cli);\n```\nSee [examples/cetcdget.c](https://github.com/shafreeck/cetcd/blob/master/examples/cetcdget.c) for more detailes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshafreeck%2Fcetcd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshafreeck%2Fcetcd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshafreeck%2Fcetcd/lists"}