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
Get a configuration applied to the current instance.
89
-
Optionally, you can pass a configuration option name to get its value.
94
+
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:
96
+
97
+
- For the current instance, ``get()`` returns an instance configuration taking into account all configuration sources, including environment variables.
98
+
- For a remote instance, ``get()`` takes into account only cluster configuration. This means that environment variables are ignored.
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>`) -- a name of a remote instance whose configuration should be obtained
104
+
92
105
:return: an instance configuration
93
106
94
107
**Examples:**
@@ -206,6 +219,67 @@ config API
206
219
...
207
220
208
221
222
+
.. _config_api_reference_instances:
223
+
224
+
.. method:: instances()
225
+
226
+
**Since:** :doc:`3.1.0 </release/3.1.0>`
227
+
228
+
List all instances of the cluster.
229
+
230
+
:return: a table containing information about instances
231
+
232
+
The returned table uses instance names as the keys and contains the following information for each instance:
233
+
234
+
- ``instance_name`` -- an instance name
235
+
- ``replicaset_name`` -- a name of the replica set the instance belongs to
236
+
- ``group_name`` -- a name of the group the instance belongs to
237
+
238
+
**Example**
239
+
240
+
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:
241
+
242
+
.. code-block:: lua
243
+
244
+
local config = require('config')
245
+
for instance_name in pairs(config:instances()) do
246
+
local connpool = require('experimental.connpool')
247
+
local conn = connpool.connect(instance_name)
248
+
local log = require('log')
249
+
log.info(string.format("Connection URI for '%s': %s:%s", instance_name, conn.host, conn.port))
250
+
end
251
+
252
+
253
+
.. _config_api_reference_instance_uri:
254
+
255
+
.. method:: instance_uri([uri_type, opts])
256
+
257
+
**Since:** :doc:`3.1.0 </release/3.1.0>`
258
+
259
+
Get a URI of the current or remote instance.
260
+
261
+
:param string uri_type: a URI type. There are two types are supported:
262
+
263
+
- ``peer`` -- a URI used to advertise the instance to other cluster members.
264
+
- ``sharding`` -- a URI used to advertise the current instance to a router and rebalancer.
265
+
266
+
See also: :ref:`configuration_reference_iproto_advertise`
267
+
268
+
:param table opts: options to pass. The following options are available:
269
+
270
+
- ``instance`` -- a name of a remote instance whose URI should be obtained
271
+
272
+
:return: an instance URI
273
+
274
+
**Example**
275
+
276
+
The example below shows how to get a URI used to advertise ``storage-b-003`` to other cluster members:
0 commit comments