Skip to content

Commit be36f2d

Browse files
authored
doc: add doc for watchcancel (#82)
1 parent e322dc3 commit be36f2d

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ install:
1010
### dev: Create a development ENV
1111
.PHONY: dev
1212
dev:
13-
luarocks install rockspec/lua-resty-etcd-master-0.1-0.rockspec --only-deps
13+
luarocks install rockspec/lua-resty-etcd-master-0.1-0.rockspec --only-deps --local
1414

1515
### help: Show Makefile rules
1616
.PHONY: help

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ luarocks install lua-resty-etcd
2828
> install by source
2929
3030
```shell
31-
$ luarocks install lua-resty-http lua-typeof
31+
$ make dev
3232
$ git clone https://github.com/iresty/lua-resty-etcd.git
3333
$ cd lua-resty-etcd
3434
$ sudo make install

api_v3.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ API V3
99
* [setx](#setx)
1010
* [delete](#delete)
1111
* [watch](#watch)
12-
* [watchdir](#watchdir)
12+
* [watchcancel](#watchcancel)
1313
* [readdir](#readdir)
1414
* [watchdir](#watchdir)
1515
* [rmdir](#rmdir)
@@ -154,6 +154,7 @@ local res, err = cli:delete('/path/to/key')
154154
* `prev_kv`: (bool) If prev_kv is set, created watcher gets the previous KV before the event happens. If the previous KV is already compacted, nothing will be returned.
155155
* `watch_id`: (int) If watch_id is provided and non-zero, it will be assigned to this watcher. Since creating a watcher in etcd is not a synchronous operation, this can be used ensure that ordering is correct when creating multiple watchers on the same stream. Creating a watcher with an ID already in use on the stream will cause an error to be returned.
156156
* `fragment`: (bool) fragment enables splitting large revisions into multiple watch responses.
157+
* `need_cancel`: (bool) if watch need to be cancel, watch would return http_cli for further cancelation. See [watchcancel](#watchcancel) for detail.
157158

158159
Watch the update of key.
159160

@@ -163,6 +164,21 @@ local res, err = cli:watch('/path/to/key')
163164

164165
[Back to TOP](#api-v3)
165166

167+
### watchcancel
168+
169+
`syntax: res, err = cli:watchcancel(http_cli:table)`
170+
171+
* `http_cli`: the http client needs to revoke.
172+
173+
Cancel the watch before it got expired. Need to set `need_cancel` to get the http client for cancelation.
174+
175+
```lua
176+
local res, err, http_cli = cli:watch('/path/to/key', {need_cancel = true})
177+
res = cli:watchcancel(http_cli)
178+
```
179+
180+
[Back to TOP](#api-v3)
181+
166182
### readdir
167183

168184
`syntax: res, err = cli:readdir(dir:string [, opts:table])`

0 commit comments

Comments
 (0)