Skip to content

Commit b357275

Browse files
committed
Update files after the review
1 parent a3a22cc commit b357275

File tree

5 files changed

+43
-37
lines changed

5 files changed

+43
-37
lines changed

doc/reference/reference_lua/box_events.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Event watchers
44
==============
55

66
The ``box`` module contains some features related to event subscriptions, also known as :term:`watchers <watcher>`.
7-
The subscriptions are used to inform a client about server-side :term:`events <event>`.
7+
The subscriptions are used to inform a client about the server-side :term:`events <event>`.
88
Each event subscription is defined by a certain key.
99

1010
.. glossary::
@@ -41,7 +41,7 @@ after the registration of the watcher.
4141
The watcher callback takes two arguments.
4242
The first argument is a name of the key for which it was registered.
4343
The second one contains current key data.
44-
The callback is always invoked in a new fiber. It means that is is okay to yield in it.
44+
The callback is always invoked in a new fiber. It means that is allowed to yield in it.
4545
A watcher callback is never executed in parallel with itself.
4646
If the key is updated while the watcher callback is running, the callback will be invoked again with the new
4747
value as soon as it returns.
@@ -71,7 +71,7 @@ Below is a list of all functions and members related to watchers or events.
7171
* - :doc:`./box_events/broadcast`
7272
- Update a state.
7373

74-
* - :ref:`˜Built-in events <system-events>`
74+
* - :ref:`Built-in events <system-events>`
7575
- Predefined events in Tarantool
7676

7777
.. toctree::

doc/reference/reference_lua/box_events/broadcast.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ box.broadcast()
2222

2323
.. code-block:: lua
2424
25-
-- Broadcast value 123 for the 'foo' key.
26-
box.broadcast('foo', 123)
25+
-- Broadcast value 42 for the 'foo' key.
26+
box.broadcast('foo', 42)
2727
2828

doc/reference/reference_lua/box_events/system_events.rst

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ The events are available from the beginning as non-:ref:`MP_NIL <box_protocol-no
1919
If a watcher subscribes to a system event before it has been broadcast,
2020
it receives an empty table for the event value.
2121

22+
The event is generated when there is a change in any of the values listed in the event.
23+
For example, see the parameters in the ``box.id`` event below -- ``id``, ``instance_uuid``, and ``replicaset_uuid``.
24+
Suppose the ``ìd`` value (``box.info.id``) has changed.
25+
This triggers the ``box.info`` event, which states that the value of ``box.info.id`` has changed,
26+
while ``box.info.uuid`` and ``box.info.cluster.uuid`` remain the same.
27+
2228
box.id
2329
~~~~~~
2430

@@ -33,7 +39,6 @@ Value changes are rare.
3339
The value is unknown before the ``box.cfg`` call.
3440

3541
* ``replicaset_uuid``: the value is unknown until the instance joins a replicaset or boots a new one.
36-
The events start working before that -- right with the start of the listen.
3742

3843
.. code-block:: lua
3944
@@ -99,28 +104,18 @@ Usage example
99104

100105
.. code-block:: lua
101106
102-
conn = net.box.connect(URI)
107+
local conn = net.box.connect(URI)
108+
local log = require('log')
103109
-- Subscribe to updates of key 'box.id'
104-
w = conn:watch('box.id', function(key, value)
110+
local w = conn:watch('box.id', function(key, value)
105111
assert(key == 'box.id')
106-
-- do something with value
107-
end)
108-
-- or to updates of key 'box.status'
109-
w = conn:watch('box.status', function(key, value)
110-
assert(key == 'box.status')
111-
-- do something with value
112-
end)
113-
-- or to updates of key 'box.election'
114-
w = conn:watch('box.election', function(key, value)
115-
assert(key == 'box.election')
116-
-- do something with value
117-
end)
118-
-- or to updates of key 'box.schema'
119-
w = conn:watch('box.schema', function(key, value)
120-
assert(key == 'box.schema')
121-
-- do something with value
112+
log.info("The box.id value is '%s'", value)
122113
end)
123-
-- Unregister the watcher when it's no longer needed.
114+
115+
If you want to unregister the watcher when it's no longer needed, use the following command:
116+
117+
.. code-block:: lua
118+
124119
w:unregister()
125120
126121

doc/reference/reference_lua/box_events/watch.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ box.watch()
1313

1414
:return: a watcher handle. The handle consists of one method -- ``unregister()``, which unregisters the watcher.
1515

16-
To read more about watchers, see the `Functions for watchers <box-watchers>` section.
16+
To read more about watchers, see the :ref:`Functions for watchers <box-watchers>` section.
1717

1818
.. note::
1919

@@ -25,13 +25,19 @@ box.watch()
2525

2626
.. code-block:: lua
2727
28-
-- Broadcast value 123 for the 'foo' key.
29-
box.broadcast('foo', 123)
28+
-- Broadcast value 42 for the 'foo' key.
29+
box.broadcast('foo', 42)
30+
31+
local log = require('log')
3032
-- Subscribe to updates of the 'foo' key.
31-
w = box.watch('foo', function(key, value)
33+
local w = box.watch('foo', function(key, value)
3234
assert(key == 'foo')
33-
-- do something with value
35+
log.info("The box.id value is '%d'", value)
3436
end)
35-
-- Unregister the watcher when it is no longer needed.
37+
38+
If you don't need the watcher anymore, you can unregister it using the command below:
39+
40+
.. code-block:: lua
41+
3642
w:unregister()
3743

doc/reference/reference_lua/net_box.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _net_box-module:
1+
zc.. _net_box-module:
22

33
--------------------------------------------------------------------------------
44
Module net.box
@@ -545,7 +545,7 @@ Below is a list of all ``net.box`` functions.
545545
:param function func: a callback to invoke when the key value is updated
546546
:return: a watcher handle. The handle consists of one method -- ``unregister()``, which unregisters the watcher.
547547

548-
To read more about watchers, see the `Functions for watchers <box-watchers>` section.
548+
To read more about watchers, see the :ref:`Functions for watchers <box-watchers>` section.
549549

550550
The method has the same syntax as the :doc:`box.watch() </reference/reference_lua/box_events/broadcast>`
551551
function, which is used for subscribing to events locally.
@@ -570,20 +570,25 @@ Below is a list of all ``net.box`` functions.
570570

571571
.. code-block:: lua
572572
573-
-- Broadcast value 123 for the key 'foo'.
574-
box.broadcast('foo', 123)
573+
-- Broadcast value 42 for the 'foo' key.
574+
box.broadcast('foo', 42)
575575
576576
Client:
577577

578578
.. code-block:: lua
579579
580580
conn = net.box.connect(URI)
581+
local log = require('log')
581582
-- Subscribe to updates of the 'foo' key.
582583
w = conn:watch('foo', function(key, value)
583584
assert(key == 'foo')
584-
-- do something with value
585+
log.info("The box.id value is '%d'", value)
585586
end)
586-
-- Unregister the watcher if it is no longer needed.
587+
588+
If you don't need the watcher anymore, you can unregister it using the command below:
589+
590+
.. code-block:: lua
591+
587592
w:unregister()
588593
589594
.. _conn-timeout:

0 commit comments

Comments
 (0)