forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net.box: introduce conn:watch_once method
Closes tarantool#6493 @TarantoolBot document Title: Document `conn:watch_once()` net.box connection method The new method takes a notification key and returns the value currently associated with it. For example, let's assume that a Tarantool server was started with the following script: ```lua box.cfg{listen = 3301} box.broadcast('foo', {1, 2, 3}) ``` Then the `conn:watch_once()` method would yield the following results: ```yaml tarantool> conn = require('net.box').connect(3301) --- ... tarantool> conn:watch_once('foo') --- - [1, 2, 3] ... tarantool> conn:watch_once('bar') --- - null ... ``` The new method can be used instead of `conn:watch()` in case the caller only needs to retrieve the current associated with a notification key value without subscribing to future changes. The method can also take a net.box options table as a second argument. It supports all the standard request options: `is_async`, `return_raw`, `timeout`, and others. They work exactly in the same way as with other net.box method, for example `conn:call`. For example, ```lua local future = conn:watch_once('foo', {is_async = true}) future:wait_result() local obj = conn:watch_once('foo', {return_raw = true}) require('msgpack').is_object(obj) ``` Like `conn:watch()`, the new method doesn't require authentication. Like `conn:watch()`, the new method can be executed in a stream (see `conn:new_stream()`), but it isn't streamlined (i.e. calling it as a stream method has the same effect as calling it as a connection method). The net.box connection will set `conn.peer_protocol_features.watch_once` to true if the remote end supports `conn:watch_once()`. The new method is implemented using the `IPROTO_WATCH_ONCE` request.
- Loading branch information
Showing
5 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## feature/core | ||
|
||
* Introduced the `conn:watch_once()` net.box connection method to get the value | ||
currently associated with a notification key on a remote instance without | ||
subscribing to future changes. The new method is implemented using the | ||
`IPROTO_WATCH_ONCE` request type (gh-6493). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters