Document `conn:watch_once()` net.box connection method
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 15
- Forks
- 49
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 3
Description
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 https://github.com/tarantool/tarantool/commit/41af3258487e1a067cb4256c146a07b241e15c54.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the net.box reference page and compare the existing conn:watch() documentation with the requested conn:watch_once() behavior. Document the return value, examples, options, authentication and stream behavior, and peer_protocol_features.watch_once support; done means the method is covered consistently in the relevant reference pages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100