Skip to content

Commit 4758194

Browse files
committed
Update files after the review
1 parent 51251d6 commit 4758194

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

doc/reference/reference_lua/box_events/system_events.rst

Lines changed: 8 additions & 16 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

@@ -100,25 +106,11 @@ Usage example
100106
.. code-block:: lua
101107
102108
local conn = net.box.connect(URI)
109+
local log = require('log')
103110
-- Subscribe to updates of key 'box.id'
104111
local w = conn:watch('box.id', function(key, value)
105112
assert(key == 'box.id')
106-
-- do something with value
107-
end)
108-
-- or subscribe 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 subscribe 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 subscribe 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
113+
log.info("The box.id value is '%s'", value)
122114
end)
123115
124116
If you want to unregister the watcher when it's no longer needed, use the following command:

doc/reference/reference_lua/box_events/watch.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ box.watch()
2121
In this case, the watcher remains registered.
2222
It is okay to discard the result of ``watch`` function if the watcher will never be unregistered.
2323

24-
**Example:**
24+
**Examples:**
2525

2626
.. code-block:: lua
2727
@@ -33,6 +33,24 @@ box.watch()
3333
-- do something with value
3434
end)
3535
36+
Server:
37+
38+
.. code-block:: lua
39+
40+
-- Broadcast value 42 for the 'foo' key.
41+
box.broadcast('foo', 42)
42+
43+
Client:
44+
45+
.. code-block:: lua
46+
47+
local conn = net.box.connect(URI)
48+
-- Subscribe to updates of the 'foo' key.
49+
local w = conn:watch('foo', function(key, value)
50+
assert(key == 'foo')
51+
-- do something with value
52+
end)
53+
3654
If you don't need the watcher anymore, you can unregister it using the command below:
3755

3856
.. code-block:: lua

doc/reference/reference_lua/net_box.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ Below is a list of all ``net.box`` functions.
570570

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

0 commit comments

Comments
 (0)