Skip to content

Commit 4de4578

Browse files
p7novandreyaksenov
andauthored
Add config labels documentation (#4360)
Resolves #4096 Co-authored-by: Andrey Aksenov <[email protected]>
1 parent d841ea7 commit 4de4578

File tree

5 files changed

+84
-1
lines changed

5 files changed

+84
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
groups:
2+
group001:
3+
replicasets:
4+
replicaset001:
5+
labels:
6+
dc: 'east'
7+
production: 'false'
8+
instances:
9+
instance001:
10+
labels:
11+
rack: '10'
12+
production: 'true'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:

doc/concepts/configuration.rst

+36
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,44 @@ Given that the ``roles`` option has the ``array`` type and ``roles_cfg`` has the
296296
farewell: 'Bye'
297297
298298
299+
.. _configuration_labels:
299300

301+
Adding labels
302+
~~~~~~~~~~~~~
303+
304+
*Labels* allow adding custom attributes to your cluster configuration. A label is
305+
an arbitrary ``key: value`` pair with a string key and value.
306+
307+
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/labels/config.yaml
308+
:language: yaml
309+
:start-at: labels:
310+
:end-at: 'false'
311+
:dedent:
312+
313+
Labels can be defined in any configuration scope. An instance receives labels from
314+
all scopes it belongs to. The ``labels`` section in a group or a replica set scope
315+
applies to all instances of the group or a replica set. To override these labels on
316+
the instance level or add instance-specific labels, define another ``labels`` section in the instance scope.
317+
318+
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/labels/config.yaml
319+
:language: yaml
320+
:dedent:
321+
322+
Example on GitHub: `labels <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/config/instances.enabled/labels>`_
323+
324+
To access instance labels from the application code, call the :ref:`config:get() <config_api_reference_get>` function:
325+
326+
.. code-block:: tarantoolsession
327+
328+
myapp:instance001> require('config'):get('labels')
329+
---
330+
- production: 'true'
331+
rack: '10'
332+
dc: east
333+
...
300334
335+
Labels can be used to direct function calls to instances that match certain criteria
336+
using the :ref:`connpool module <connpool_module>`.
301337

302338
.. _configuration_predefined_variables:
303339

doc/reference/configuration/configuration_reference.rst

+31
Original file line numberDiff line numberDiff line change
@@ -2462,6 +2462,37 @@ instances
24622462
Any configuration parameter that can be defined in the instance :ref:`scope <configuration_scopes>`.
24632463
For example, :ref:`iproto <configuration_reference_iproto>` and :ref:`database <configuration_reference_database>` configuration parameters defined at the instance level are applied to this instance only.
24642464

2465+
.. _configuration_reference_labels:
2466+
2467+
labels
2468+
------
2469+
2470+
The ``labels`` section allows adding custom attributes to the configuration.
2471+
Attributes must be ``key: value`` pairs with string keys and values.
2472+
2473+
2474+
.. NOTE::
2475+
2476+
``labels`` can be defined in any :ref:`scope <configuration_scopes>`.
2477+
2478+
- :ref:`labels.\<label_name\> <configuration_reference_labels_name>`
2479+
2480+
.. _configuration_reference_labels_name:
2481+
2482+
.. confval:: labels.<label_name>
2483+
2484+
A value of the label with the specified name.
2485+
2486+
**Example**
2487+
2488+
The example below shows how to define labels on the replica set and instance levels:
2489+
2490+
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/labels/config.yaml
2491+
:language: yaml
2492+
:dedent:
2493+
2494+
See also: :ref:`configuration_labels`
2495+
24652496
.. _configuration_reference_log:
24662497

24672498
log

doc/release/3.1.0.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ In the 3.1 version, this module provides the following API:
197197
198198
199199
* The ``filter()`` function returns the names of instances that match the specified conditions.
200-
In the example below, this function returns a list of instances with the ``storage`` role and specified label value:
200+
In the example below, this function returns a list of instances with the ``storage`` role and specified
201+
:ref:`label <configuration_labels>` value:
201202

202203
.. code-block:: tarantoolsession
203204
@@ -216,11 +217,13 @@ In the 3.1 version, this module provides the following API:
216217

217218
.. code-block:: tarantoolsession
218219
220+
sharded_cluster:router-a-001> connpool.call('vshard.storage.buckets_count', nil, { roles = { 'storage' }, labels = { dc = 'west' }, mode = 'rw' })
219221
sharded_cluster:router-a-001> connpool.call('vshard.storage.buckets_count', nil, { roles = { 'storage' }, labels = { dc = 'west' }, mode = 'rw' })
220222
---
221223
- 500
222224
...
223225
226+
Learn more in the ``experimental.connpool`` :ref:`module reference <connpool_module>`.
224227

225228

226229
.. _3-1-accessing_configuration:

0 commit comments

Comments
 (0)