{"id":21970789,"url":"https://github.com/kingluo/lua-resty-ffi-etcd","last_synced_at":"2025-04-28T11:28:39.895Z","repository":{"id":167928282,"uuid":"643517012","full_name":"kingluo/lua-resty-ffi-etcd","owner":"kingluo","description":"openresty etcd client library","archived":false,"fork":false,"pushed_at":"2023-05-21T15:11:33.000Z","size":27,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T09:11:33.877Z","etag":null,"topics":["etcd-client","etcdv3","golang","luajit","nginx","openresty"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kingluo.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-05-21T12:20:48.000Z","updated_at":"2024-07-10T01:02:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae1a1a65-a990-4c4c-af3d-f68d0e34e328","html_url":"https://github.com/kingluo/lua-resty-ffi-etcd","commit_stats":null,"previous_names":["kingluo/lua-resty-ffi-etcd"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingluo%2Flua-resty-ffi-etcd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingluo%2Flua-resty-ffi-etcd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingluo%2Flua-resty-ffi-etcd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingluo%2Flua-resty-ffi-etcd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kingluo","download_url":"https://codeload.github.com/kingluo/lua-resty-ffi-etcd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251304177,"owners_count":21567831,"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":["etcd-client","etcdv3","golang","luajit","nginx","openresty"],"created_at":"2024-11-29T14:43:08.991Z","updated_at":"2025-04-28T11:28:39.876Z","avatar_url":"https://github.com/kingluo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lua-resty-ffi-etcd\n\nThe openresty etcd client library.\n\nIt encapsulates the etcd official [go client library](https://pkg.go.dev/go.etcd.io/etcd/client/v3).\n\n## Background\n\nIf you access etcd directly using bare HTTP/GRPC, you will face the following problems:\n\n* [smart load balancer](https://etcd.io/docs/v3.5/learning/design-client/) for multi-nodes etcd cluster\n  * Sync cluster membership changes, e.g. replace a stale node\n  * Full-featured node health check based on etcd client design\n  * Conditional retry\n* Compose low-level APIs to do some high-level stuff like authentication\n* Lack of support for additional features like [grpc-proxy](https://etcd.io/docs/v3.5/op-guide/grpc_proxy/#client-endpoint-synchronization-and-name-resolution)\n* Keep up-to-date with etcd official server code changes and fix bugs yourself\n\nSince etcd has an brilliant and active official go client, why not encapsulate it so that we could reuse it in openresty?\n\n[lua-resty-ffi](https://github.com/kingluo/lua-resty-ffi) provides an efficient and generic API to do hybrid programming\nin openresty with mainstream languages (Go, Python, Java, Rust, Nodejs).\n\n`lua-resty-ffi-etcd = lua-resty-ffi + go-etcd`\n\n## Synopsis\n\n```lua\nlocal etcd = require(\"resty.ffi.etcd\")\nlocal inspect = require(\"inspect\")\n\nlocal client = etcd.new{\n    endpoints = {\n        \"httpbin.local:2379\",\n    },\n}\nlocal watch = client:watch{\n    key = \"/apisix/\",\n    is_prefix = true,\n}\nlocal ok, res = watch:recv()\nassert(ok, \"watch:recv failed\")\nngx.say(inspect(res))\n```\n\n## Demo\n\n```bash\n# install lua-resty-ffi\n# https://github.com/kingluo/lua-resty-ffi#install-lua-resty-ffi-via-luarocks\n# set `OR_SRC` to your openresty source path\nluarocks config variables.OR_SRC /tmp/tmp.Z2UhJbO1Si/openresty-1.21.4.1\nluarocks install lua-resty-ffi\n\ncd /opt\ngit clone https://github.com/kingluo/lua-resty-ffi-etcd\ncd /opt/lua-resty-ffi-etcd\nmake\n\ncd /opt/lua-resty-ffi-etcd/demo\n\n# run nginx\nLD_LIBRARY_PATH=/opt/lua-resty-ffi-etcd:/usr/local/lib/lua/5.1 \\\nnginx -p $PWD -c nginx.conf\n\n# in another terminal, run demo\ncurl localhost:20000/demo/watch\n```\n\n### Benchmark\n\n![etcd_benchmark](etcd_benchmark.svg)\n\nhttps://github.com/kingluo/etcd-benchmark\n\nThe overhead of encapsulation is approximately `20%`. Of course, there is improvement room.\n\n### TODO\n\n* [x] Watcher\n* [ ] KV\n* [ ] Lease\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingluo%2Flua-resty-ffi-etcd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkingluo%2Flua-resty-ffi-etcd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingluo%2Flua-resty-ffi-etcd/lists"}