@@ -30,15 +30,12 @@ In Tarantool, :term:`pub/sub <publisher/subscriber>` is a :term:`notification` s
30
30
31
31
The pub/sub pattern is associated with subscriptions.
32
32
Each subscription is defined by the certain key.
33
- The main feature of the subscriptions is a one-time action.
34
- It means that if the server generates too many events and a client is too slow,
35
- the server will not allocate additional memory.
36
33
37
34
Built-in events for pub/sub
38
35
---------------------------
39
36
40
- Built-in events have a special naming schema -- theirs names always start with the ``box. `` prefix.
41
- This prefix is reserved for the built-in events. It means that you cannot create new events with it.
37
+ Predefined events have a special naming schema -- theirs names always start with the reserved ``box. `` prefix.
38
+ It means that you cannot create new events with it.
42
39
43
40
The system processes the following events:
44
41
@@ -47,23 +44,34 @@ The system processes the following events:
47
44
* ``box.election ``
48
45
* ``box.schema ``
49
46
50
- In response to each event, the server sends back certain IPROTO fields.
47
+ In response to each event, the server sends back certain ``IPROTO `` fields.
48
+
49
+ The events are available from the beginning as non-:ref: `MP_NIL <box_protocol-notation >`.
50
+ If the events are broadcast before :doc: `box.cfg{} </reference/reference_lua/box_cfg >`,
51
+ then the events values are empty:
52
+
53
+ .. code-block :: lua
54
+
55
+ box.id = {}
56
+ box.schema = {}
57
+ box.status = {}
58
+ box.election = {}
51
59
52
60
box.id
53
61
~~~~~~
54
62
55
- Contains identification of the instance.
56
- Changes are particularly rare.
57
- Some values never change or change only once.
63
+ Contains :ref: `identification <box_info_info >` of the instance.
64
+ Value changes are rare.
58
65
59
- The numeric instance ID is known only after registration.
60
- For anonymous replicas, the value is ``0 `` until they are officially registered.
66
+ * `` id ``: the numeric instance ID is unknown before the registration.
67
+ For anonymous replicas, the value is ``0 `` until they are officially registered.
61
68
62
- The UUID of the instance never changes after the first :doc: `box.cfg </reference/reference_lua/box_cfg >`.
63
- The value is unknown before the ``box.cfg `` call.
69
+ * ``instance_uuid ``: the UUID of the instance never changes after the first
70
+ :doc: `box.cfg </reference/reference_lua/box_cfg >`.
71
+ The value is unknown before the ``box.cfg `` call.
64
72
65
- The replicaset UUID is unknown until the instance joins a replicaset or boots a new one.
66
- The events are supposed to start working before that -- right with the start of the listen.
73
+ * `` replicaset_uuid ``: the value is unknown until the instance joins a replicaset or boots a new one.
74
+ The events start working before that -- right with the start of the listen.
67
75
68
76
.. code-block :: lua
69
77
@@ -78,8 +86,10 @@ box.status
78
86
~~~~~~~~~~
79
87
80
88
Contains generic blob about the instance status.
81
- There are the most frequently used and not frequently changed
82
- :doc: `config options </reference/reference_lua/box_cfg >` and :doc: `box.info </reference/reference_lua/box_info >` fields.
89
+
90
+ * ``is_ro ``: :ref: `indicates the read-only mode <box_introspection-box_info >` or the ``orphan `` status.
91
+ * ``is_ro_cfg ``: indicates the :ref: `read_only <cfg_basic-read_only >` mode for the instance.
92
+ * ``status ``: shows the status of an instance.
83
93
84
94
.. code-block :: lua
85
95
@@ -92,8 +102,13 @@ There are the most frequently used and not frequently changed
92
102
box.election
93
103
~~~~~~~~~~~~
94
104
95
- Contains all the required parts of :doc: `box.info.election </reference/reference_lua/box_info/election >`
96
- that are necessary to find out who is the most recent writable leader.
105
+ Contains fields of the :doc: `box.info.election </reference/reference_lua/box_info/election >`
106
+ that are necessary to find out the most recent writable leader.
107
+
108
+ * ``term ``: shows the current election term.
109
+ * ``role ``: indicates the election state of the node -- ``leader ``, ``follower ``, or ``candidate ``.
110
+ * ``is_ro ``: :ref: `indicates the read-only mode <box_introspection-box_info >` or the ``orphan `` status.
111
+ * ``leader ``: shows the leader node ID in the current term.
97
112
98
113
.. code-block :: lua
99
114
@@ -108,31 +123,15 @@ box.schema
108
123
~~~~~~~~~~
109
124
110
125
Contains schema-related data.
111
- Currently, it contains only the version.
126
+
127
+ * ``version ``: shows the schema version.
112
128
113
129
.. code-block :: lua
114
130
115
131
{
116
132
MP_STR “version”: MP_UINT schema_version,
117
133
}
118
134
119
- The events are available from the beginning as non-:ref: `MP_NIL <box_protocol-notation >`.
120
- It is necessary for supported local subscriptions.
121
- Otherwise, there is no way to detect whether an event is supported at all by this Tarantool version.
122
- If the events are broadcast before :doc: `box.cfg{} </reference/reference_lua/box_cfg >`,
123
- then the following values are available:
124
-
125
- .. code-block :: lua
126
-
127
- box.id = {}
128
- box.schema = {}
129
- box.status = {}
130
- box.election = {}
131
-
132
- This way, users can distinguish if an event being not supported
133
- at all or if ``box.cfg{} `` has not been called yet.
134
- Otherwise, they would need to parse the ``_TARANTOOL `` version string locally and the ``peer_version `` in ``net.box ``.
135
-
136
135
Usage example
137
136
-------------
138
137
0 commit comments