{"id":21558352,"url":"https://github.com/doublespout/resty-etcdv2","last_synced_at":"2025-03-18T03:28:42.486Z","repository":{"id":141858087,"uuid":"211745186","full_name":"DoubleSpout/resty-etcdv2","owner":"DoubleSpout","description":"support etcdv2 for openresty, fork by lua-resty-etcd, test travis ci","archived":false,"fork":false,"pushed_at":"2019-10-28T02:13:29.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-24T10:47:25.784Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","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/DoubleSpout.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":"2019-09-30T00:33:00.000Z","updated_at":"2019-10-28T02:13:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"98bbe153-34fe-4d5e-88e2-f684bfa444a5","html_url":"https://github.com/DoubleSpout/resty-etcdv2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoubleSpout%2Fresty-etcdv2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoubleSpout%2Fresty-etcdv2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoubleSpout%2Fresty-etcdv2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoubleSpout%2Fresty-etcdv2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DoubleSpout","download_url":"https://codeload.github.com/DoubleSpout/resty-etcdv2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244149272,"owners_count":20406340,"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-11-24T08:14:37.365Z","updated_at":"2025-03-18T03:28:42.481Z","avatar_url":"https://github.com/DoubleSpout.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"resty-etcdv2\n====\n\n[resty-etcd](https://github.com/iresty/lua-resty-etcd) Nonblocking Lua etcd driver library for OpenResty, this module supports etcd API v2.\n\n[![Build Status](https://travis-ci.org/DoubleSpout/resty-etcdv2.svg?branch=master)](https://travis-ci.org/DoubleSpout/resty-etcdv2)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/iresty/lua-resty-etcd/blob/master/LICENSE)\n\nTable of Contents\n=================\n* [Install](#install)\n* [Methods](#methods)\n    * [new](#new)\n    * [get](#get)\n    * [set](#set)\n    * [setnx](#setnx)\n    * [setx](#setx)\n    * [delete](#delete)\n    * [wait](#wait)\n    * [readdir](#readdir)\n    * [mkdir](#mkdir)\n    * [rmdir](#rmdir)\n    * [waitdir](#waitdir)\n    * [push](#push)\n    * [version](#version)\n    * [stats_leader](#stats_leader)\n    * [stats_self](#stats_self)\n    * [stats_store](#stats_store)\n\n\n## Install\n\n\u003e Dependencies\n\n- lua-resty-http: https://github.com/ledgetech/lua-resty-http\n- lua-typeof: https://github.com/iresty/lua-typeof\n\n\u003e install by luarocks\n\n```shell\nluarocks install lua-resty-etcd\n```\n\n\u003e install by source\n\n```shell\n$ luarocks install lua-resty-http lua-typeof\n$ git clone https://github.com/iresty/lua-resty-etcd.git\n$ cd lua-resty-etcd\n$ sudo make install\n```\n\n[Back to TOC](#table-of-contents)\n\nMethod\n======\n\n### new\n\n`syntax: cli, err = etcd.new([option:table])`\n\n- `option:table`\n  - `host`: string - default `http://127.0.0.1:2379`\n  - `ttl`: int - default `-1`\n    default ttl for key operation. set -1 to disable ttl.\n  - `prefix`: string\n    append this prefix path string to key operation url `'/v2/keys'`.\n  - `timeout`: int\n    request timeout seconds.\n\nThe client methods returns either a `HTTP Response Entity` or an `error string`.\n\n`HTTP Response Entity` contains the following fields except `408` timeout status;\n\n- `status`: number - HTTP status code.\n- `header`: table - response header if `status` is not `408` timeout status.\n- `body`: string or table - response body if `status` is not `408` timeout status.\n\n**Note:** a client method will decode a response body as a JSON string if a `Content-Type` response header value is a `application/json`.\n\n```lua\nlocal cli, err = require('resty.etcd').new()\n```\n\nPlease refer the **etcd API documentaion** at - https://github.com/coreos/etcd for more details of a response entity.\n\n[Back to TOC](#table-of-contents)\n\n### get\n\n`syntax: res, err = cli:get(key:string)`\n\nGets the value for key.\n\n```lua\nlocal res, err = cli:get('/path/to/key')\n```\n\n[Back to TOC](#table-of-contents)\n\n### set\n\n`syntax: res, err = cli:set(key:string, val:JSON value [, ttl:int])`\n\nSet a key-value pair.\n\n```lua\nlocal res, err = cli:set('/path/to/key', 'val', 10)\n```\n\n[Back to TOC](#table-of-contents)\n\n### setnx\n\n`syntax: res, err = cli:setnx(key:string, val:JSON value [, ttl:int])`\n\nSet a key-value pair if that key does not exist.\n\n```lua\nlocal res, err = cli:setnx('/path/to/key', 'val', 10)\n```\n\n[Back to TOC](#table-of-contents)\n\n### setx\n\n`syntax: res, err = cli:setx(key:string, val:JSON value [, ttl:int [, modified_index:uint] ])`\n\n- `modified_index`: uint - this argument to use to the `prev_index` query of atomic operation.\n\nSet a key-value pair when that key is exists.\n\n```lua\nlocal res, err = cli:setx('/path/to/key', 'val', 10)\n```\n\n```lua\nlocal res, err = cli:get('/path/to/key')\n\n-- this operation will be failed if the `modified_index` of specified key\n-- has already been updated by another client.\nres, err = cli:setx('/path/to/key', 'val', 10, res.body.node.modifiedIndex)\n```\n\n[Back to TOC](#table-of-contents)\n\n### delete\n\n`syntax: res, err = cli:delete(key:string [, val:JSON value [, modified_index:uint] ])`\n\n- `val`: JSON value - this argument to use to the `prevValue` query of atomic operation.\n- `modified_index`: uint - this argument to use to the `prev_index` query of atomic operation.\n\nDeletes a key-value pair.\n\n```lua\nlocal res, err = cli:delete('/path/to/key')\n```\n\n```lua\nlocal res, err = cli:get('/path/to/key')\n\n-- delete key-value pair if both of `value` and `modified_index` has matched\n-- to the passed arguments\nres, err = cli:delete('/path/to/key', res.body.node.value,\n                      res.body.node.modifiedIndex)\n\n-- delete key-value pair if `value` has matched to the passed value\nres, err = cli:delete('/path/to/key', res.body.node.value)\n\n-- delete key-value pair if `modified_index` has matched to the passed\n-- modifiedIndex\nres, err = cli:delete('/path/to/key', nil, res.body.node.modifiedIndex)\n\n```\n\n[Back to TOC](#table-of-contents)\n\n### wait\n\n`syntax: res, err = cli:wait(key:string [, modified_index:uint [, timeout:uint] ]) `\n\n- `modified_index`: uint - this argument to use to the `prev_index` query of atomic operation.\n- `timeout`: uint - request timeout seconds. set 0 to disable timeout.\n\nWait the update of key.\n\n```lua\nlocal res, err = cli:wait('/path/to/key')\n```\n\n```lua\nlocal res, err = cli:get('/path/to/key')\n\n-- Wait forever the update of key until that modifiedIndex of key has changed\n-- to modifiedIndex + 1\nres, err = cli:wait('/path/to/key', res.body.node.modifiedIndex + 1, 0)\n\n-- Wait for 10 seconds the update of key until that modifiedIndex of key has\n-- changed to modifiedIndex + 2\nres, err = cli:wait('/path/to/key', res.body.node.modifiedIndex + 2, 10)\n```\n\n[Back to TOC](#table-of-contents)\n\n### readdir\n\n`syntax: res, err = cli:readdir(key:string [, recursive:boolean])`\n\n- `recursive`: boolean - get all the contents under a directory.\n\nRead the directory.\n\n```lua\nlocal res, err = cli:readdir('/path/to/dir')\n```\n\n[Back to TOC](#table-of-contents)\n\n### mkdir\n\n`syntax: res, err = cli:mkdir(key:string [, ttl:int])`\n\nCreates a directory.\n\n```lua\nlocal res, err = cli:mkdir('/path/to/dir', 10)\n```\n\n[Back to TOC](#table-of-contents)\n\n### mkdirnx\n\n`syntax: res, err = cli:mkdirnx(key:string [, ttl:int])`\n\nCreates a directory if that directory does not exist.\n\n```lua\nlocal res, err = cli:mkdirnx('/path/to/dir', 10)\n```\n\n[Back to TOC](#table-of-contents)\n\n### rmdir\n\n`syntax: res, err = cli:rmdir(key:string [, recursive:boolean])`\n\n- `recursive`: boolean - remove all the contents under a directory.\n\nRemove the directory\n\n```lua\nlocal res, err = cli:rmdir('/path/to/dir')\n```\n\n[Back to TOC](#table-of-contents)\n\n### waitdir\n\n`syntax: res, err = cli:waitdir(key:string [, modified_index:uint [, timeout:uint] ])`\n\n\n- `modified_index`: uint - this argument to use to the `prev_index` query of atomic operation.\n- `timeout`: uint - request timeout seconds. set 0 to disable timeout.\n\n```lua\nlocal res, err = cli:waitdir('/path/to/dir')\n```\n\n[Back to TOC](#table-of-contents)\n\n### push\n\n`syntax: res, err = cli:push(key:string, val:JSON value [, ttl:int])`\n\nPushs a value into the specified directory.\n\n```lua\nlocal res, err = cli:mkdir('/path/to/dir')\nres, err = cli:push('/path/to/dir', 'val', 10)\n```\n\n[Back to TOC](#table-of-contents)\n\n### version\n\n`syntax: res, err = cli:version()`\n\nGets the etcd version info.\n\n[Back to TOC](#table-of-contents)\n\n### stats_leader\n\n`syntax: res, err = cli:stats_leader()`\n\nGets the leader statistics info.\n\n[Back to TOC](#table-of-contents)\n\n### stats_self\n\n`syntax: res, err = cli:stats_self()`\n\nGets the self statistics info.\n\n[Back to TOC](#table-of-contents)\n\n### stats_store\n\n`syntax: res, err = cli:stats_store()`\n\nGets the store statistics info.\n\n[Back to TOC](#table-of-contents)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoublespout%2Fresty-etcdv2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoublespout%2Fresty-etcdv2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoublespout%2Fresty-etcdv2/lists"}