@@ -19,6 +19,12 @@ The events are available from the beginning as non-:ref:`MP_NIL <box_protocol-no
19
19
If a watcher subscribes to a system event before it has been broadcast,
20
20
it receives an empty table for the event value.
21
21
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
+
22
28
box.id
23
29
~~~~~~
24
30
@@ -100,25 +106,11 @@ Usage example
100
106
.. code-block :: lua
101
107
102
108
local conn = net.box.connect(URI)
109
+ local log = require('log')
103
110
-- Subscribe to updates of key 'box.id'
104
111
local w = conn:watch('box.id', function(key, value)
105
112
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)
122
114
end)
123
115
124
116
If you want to unregister the watcher when it's no longer needed, use the following command:
0 commit comments