Skip to content

Document conn:watch_once() net.box connection method #3512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
TarantoolBot opened this issue Jun 13, 2023 · 1 comment
Open

Document conn:watch_once() net.box connection method #3512

TarantoolBot opened this issue Jun 13, 2023 · 1 comment
Labels
3.0 feature A new functionality netbox [area] Related to net.box reference [location] Tarantool manual, Reference part

Comments

@TarantoolBot
Copy link
Collaborator

TarantoolBot commented Jun 13, 2023

Product: Tarantool
Since: 3.0
Root document: https://www.tarantool.io/en/doc/latest/dev_guide/internals/iproto/requests/
https://www.tarantool.io/en/doc/latest/reference/reference_lua/net_box/
https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_events/
SME: @ locker

Details

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:

box.cfg{listen = 3301}
box.broadcast('foo', {1, 2, 3})

Then the conn:watch_once() method would yield the following results:

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,

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.
Requested by @locker in tarantool/tarantool@41af325.

@locker
Copy link
Member

locker commented Jun 13, 2023

Related issues: #3510 #3511

@xuniq xuniq added 3.0 feature A new functionality netbox [area] Related to net.box reference [location] Tarantool manual, Reference part labels Sep 21, 2023
@xuniq xuniq self-assigned this Sep 21, 2023
@xuniq xuniq removed their assignment Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0 feature A new functionality netbox [area] Related to net.box reference [location] Tarantool manual, Reference part
Projects
None yet
Development

No branches or pull requests

3 participants