You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/reference/reference_lua/config.rst
+91-10Lines changed: 91 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Module config
8
8
The ``config`` module provides the ability to work with an instance's configuration.
9
9
For example, you can determine whether the current instance is up and running without errors after applying the :ref:`cluster's configuration <configuration_overview>`.
10
10
11
-
By using the ``config.storage`` :ref:`role <configuration_reference_roles_options>`, you can set up a Tarantool-based :ref:`centralized configuration storage <configuration_etcd>` and interact with this storage using the ``config`` module API.
11
+
By using the ``config.storage`` :ref:`role <configuration_application_roles>`, you can set up a Tarantool-based :ref:`centralized configuration storage <configuration_etcd>` and interact with this storage using the ``config`` module API.
Get a configuration applied to the current or remote instance.
95
+
Note that there is the following difference between getting a configuration for the current and remote instance:
87
96
88
-
Get a configuration applied to the current instance.
89
-
Optionally, you can pass a configuration option name to get its value.
97
+
- For the current instance, ``get()`` returns an instance configuration considering :ref:`environment variables <configuration_environment_variable>`.
98
+
- For a remote instance, ``get()`` only considers a cluster configuration and ignores environment variables.
90
99
91
100
:param string param: a configuration option name
101
+
:param table opts: options to pass. The following options are available:
102
+
103
+
- ``instance`` (since :doc:`3.1.0 </release/3.1.0>`) -- the name of a remote instance whose configuration should be obtained
104
+
92
105
:return: an instance configuration
93
106
94
107
**Examples:**
@@ -104,7 +117,7 @@ config API
104
117
too_long_threshold: 0.5
105
118
top:
106
119
enabled: false
107
-
# other configuration values
120
+
# Other configuration values
108
121
# ...
109
122
110
123
This example shows how to get an ``iproto.listen`` option value:
@@ -121,10 +134,19 @@ config API
121
134
122
135
.. _config_api_reference_info:
123
136
124
-
.. method:: info()
137
+
.. method:: info([version])
125
138
126
139
Get the current instance's state in regard to configuration.
127
140
141
+
:param string version: (since :doc:`3.1.0 </release/3.1.0>`) the version of the information that should be returned. The ``version`` argument can be one of the following values:
142
+
143
+
* ``v1`` (default): the ``meta`` field returned by ``info()`` includes information about the last loaded configuration
144
+
* ``v2``: the ``meta`` field returned by ``info()`` includes two fields:
145
+
146
+
* the ``last`` field includes information about the last loaded configuration
147
+
* the ``active`` field includes information for the last successfully applied configuration
148
+
149
+
128
150
:return: a table containing an instance's state
129
151
130
152
The returned state includes the following sections:
@@ -155,7 +177,7 @@ config API
155
177
...
156
178
157
179
* In the example below, the instance's state is ``check_warnings``.
158
-
The ``alerts`` section informs that privileges to the ``books`` space for ``sampleuser`` cannot be granted because the ``books`` space has not created yet:
180
+
The ``alerts`` section informs that privileges to the ``books`` space for ``sampleuser`` cannot be granted because the ``books`` space has not been created yet:
159
181
160
182
.. code-block:: console
161
183
@@ -205,6 +227,65 @@ config API
205
227
alerts: []
206
228
...
207
229
230
+
.. _config_api_reference_instance_uri:
231
+
232
+
.. method:: instance_uri([uri_type, opts])
233
+
234
+
**Since:** :doc:`3.1.0 </release/3.1.0>`
235
+
236
+
Get a URI of the current or remote instance.
237
+
238
+
:param string uri_type: a URI type. There are the following URI types are supported:
239
+
240
+
* ``peer`` -- a URI used to advertise the instance to other cluster members. See also: :ref:`iproto.advertise.peer <configuration_reference_iproto_advertise_peer>`.
241
+
* ``sharding`` -- a URI used to advertise the current instance to a router and rebalancer. See also: :ref:`iproto.advertise.sharding <configuration_reference_iproto_advertise_sharding>`.
242
+
243
+
:param table opts: options to pass. The following options are available:
244
+
245
+
- ``instance`` -- the name of a remote instance whose URI should be obtained
246
+
247
+
:return: an instance URI
248
+
249
+
**Example**
250
+
251
+
The example below shows how to get a URI used to advertise ``storage-b-003`` to other cluster members:
:return: a table containing information about instances
268
+
269
+
The returned table uses instance names as the keys and contains the following information for each instance:
270
+
271
+
- ``instance_name`` -- an instance name
272
+
- ``replicaset_name`` -- the name of a replica set the instance belongs to
273
+
- ``group_name`` -- the name of a group the instance belongs to
274
+
275
+
**Example**
276
+
277
+
The example below shows how to use ``instances()`` to get the names of all instances in the cluster, create a connection to each instance using the :ref:`connpool <connpool_module>` module, and log connection URIs using the :ref:`log <log-module>` module:
278
+
279
+
.. code-block:: lua
280
+
281
+
local config = require('config')
282
+
for instance_name in pairs(config:instances()) do
283
+
local connpool = require('experimental.connpool')
284
+
local conn = connpool.connect(instance_name)
285
+
local log = require('log')
286
+
log.info(string.format("Connection URI for '%s': %s:%s", instance_name, conn.host, conn.port))
287
+
end
288
+
208
289
209
290
.. _config_api_reference_reload:
210
291
@@ -268,7 +349,7 @@ The ``config.storage`` API allows you to interact with a Tarantool-based :ref:`c
268
349
* ``data``: a table containing the information about the value:
269
350
270
351
* ``path``: a path
271
-
* ``mod_revision``: a last revision at which this value was modified
352
+
* ``mod_revision``: the last revision at which this value was modified
272
353
* ``value:``: a value
273
354
274
355
* ``revision``: a revision after performing the operation
@@ -308,7 +389,7 @@ The ``config.storage`` API allows you to interact with a Tarantool-based :ref:`c
308
389
* ``data``: a table containing the information about the value:
309
390
310
391
* ``path``: a path
311
-
* ``mod_revision``: a last revision at which this value was modified
392
+
* ``mod_revision``: the last revision at which this value was modified
312
393
* ``value:``: a value
313
394
314
395
* ``revision``: a revision after performing the operation
0 commit comments