Skip to content

Commit 3ffa4fd

Browse files
committed
Centralized storage: update per review
1 parent 4c38036 commit 3ffa4fd

File tree

3 files changed

+53
-48
lines changed

3 files changed

+53
-48
lines changed

doc/concepts/configuration.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ There are two approaches to configuring Tarantool:
1111
* *Since version 3.0*: In the YAML format.
1212

1313
YAML configuration allows you to provide the full cluster topology and specify all configuration options.
14-
You can use local configuration in a YAML file for each instance or store configuration data in one reliable place using :ref:`etcd <configuration_etcd_overview>`.
14+
You can use local configuration in a YAML file for each instance or store configuration data in a reliable :ref:`centralized storage <configuration_etcd_overview>`.
1515

1616
* *In version 2.11 and earlier*: :ref:`In code <configuration_code>` using the ``box.cfg`` API.
1717

@@ -335,7 +335,7 @@ Centralized configuration
335335
:end-before: ee_note_centralized_config_end
336336

337337

338-
Tarantool enables you to store configuration data in one reliable place, for example, a Tarantool or etcd-based configuration storage.
338+
Tarantool enables you to store configuration data in one place using a Tarantool or etcd-based storage.
339339
To achieve this, you need to:
340340

341341
1. Set up a centralized configuration storage.

doc/concepts/configuration/configuration_etcd.rst

Lines changed: 38 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,33 @@ Centralized configuration storages
1414
1515
**Examples on GitHub**: `centralized_config <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/centralized_config/>`_
1616

17-
Tarantool enables you to store configuration data in one place using a Tarantool or etcd-based storage.
17+
Tarantool enables you to store a cluster's configuration in one reliable place using a Tarantool or etcd-based storage:
18+
19+
- A Tarantool-based configuration storage is a replica set that stores a cluster's configuration in :ref:`synchronous <repl_sync>` spaces.
20+
- `etcd <https://etcd.io/>`__ is a distributed key-value storage for any type of critical data used by distributed systems.
21+
1822
With a :ref:`local YAML configuration <configuration_file>`, you need to make sure that all cluster instances use identical configuration files:
1923

24+
|
25+
2026
.. image:: tarantool_config_local.png
2127
:align: left
2228
:width: 500
2329
:alt: Local configuration file
2430

31+
|
32+
2533
Using a centralized configuration storage, all instances get the actual configuration from one place:
2634

35+
|
36+
2737
.. image:: tarantool_config_centralized.png
2838
:align: left
2939
:width: 500
3040
:alt: Centralized configuration storage
3141

42+
|
43+
3244
This topic describes how to set up a configuration storage, publish a cluster configuration to this storage, and use this configuration for all cluster instances.
3345

3446

@@ -43,7 +55,6 @@ Setting up a configuration storage
4355
Tarantool-based storage
4456
~~~~~~~~~~~~~~~~~~~~~~~
4557

46-
A Tarantool-based storage is a replica set that stores configuration data in :ref:`synchronous <repl_sync>` spaces.
4758
To make a replica set act as a configuration storage, use the built-in ``config.storage`` :ref:`role <configuration_reference_roles_options>`.
4859

4960

@@ -117,46 +128,6 @@ Learn more from the :ref:`Starting and stopping instances <admin-start_stop_inst
117128

118129

119130

120-
.. _centralized_configuration_storage_tarantool_interact:
121-
122-
Interacting with the storage
123-
****************************
124-
125-
The :ref:`config module <config-module>` provides the API for interacting with the configuration storage.
126-
For example, you can get the configuration stored by the specified path using the ``config.storage.get()`` function:
127-
128-
.. literalinclude:: /code_snippets/snippets/centralized_config/instances.enabled/tarantool_config_storage/myapp.lua
129-
:language: lua
130-
:start-after: get_config_by_path
131-
:end-at: get('/myapp/config/all')
132-
:dedent:
133-
134-
To get all configurations stored by the specified prefix (ending with ``/``), pass it to ``config.storage.get()``:
135-
136-
.. literalinclude:: /code_snippets/snippets/centralized_config/instances.enabled/tarantool_config_storage/myapp.lua
137-
:language: lua
138-
:start-after: get_config_by_prefix
139-
:end-at: get('/myapp/')
140-
:dedent:
141-
142-
Learn more from the :ref:`config_storage_api_reference` section.
143-
144-
145-
.. _centralized_configuration_storage_tarantool_watch_changes:
146-
147-
Watching configuration updates
148-
******************************
149-
150-
The ``net.box module`` provides the ability to monitor configuration updates by watching path or prefix changes.
151-
In the example below, :ref:`conn:watch() <conn-watch>` is used to monitor updates of a configuration stored by the ``/myapp/config/all`` path:
152-
153-
.. literalinclude:: /code_snippets/snippets/centralized_config/instances.enabled/config_storage/myapp.lua
154-
:language: lua
155-
:dedent:
156-
157-
You can find the full example here: `config_storage <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/centralized_config/instances.enabled/config_storage>`_.
158-
159-
160131

161132
.. _centralized_configuration_storage_set_up_etcd:
162133

@@ -213,7 +184,7 @@ To publish a cluster's configuration (``source.yaml``) to a centralized storage,
213184

214185
.. code-block:: console
215186
216-
$ tt cluster publish "http://localhost:2379/myapp" source.yaml
187+
$ tt cluster publish "http://sampleuser:123456@localhost:2379/myapp" source.yaml
217188
218189
Executing this command publishes a cluster configuration by the ``/myapp/config/all`` path.
219190

@@ -222,12 +193,34 @@ Executing this command publishes a cluster configuration by the ``/myapp/config/
222193
You can see a cluster's configuration using the ``tt cluster show`` command.
223194

224195

196+
197+
.. _centralized_configuration_storage_publish_config_tarantool:
198+
199+
Publishing configuration using the 'config' module
200+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
201+
202+
The :ref:`config module <config-module>` provides the API for interacting with a Tarantool-based configuration storage.
203+
The example below shows how to read a configuration stored in the ``source.yaml`` file using the :ref:`fio module <fio-module>` API and put this configuration by the ``/myapp/config/all`` path:
204+
205+
.. literalinclude:: /code_snippets/snippets/centralized_config/instances.enabled/tarantool_config_storage/myapp.lua
206+
:language: lua
207+
:start-after: function put_config
208+
:end-at: cluster_config_handle:close()
209+
:dedent:
210+
211+
Learn more from the :ref:`config_storage_api_reference` section.
212+
213+
.. NOTE::
214+
215+
The ``net.box module`` provides the ability to monitor configuration updates by watching path or prefix changes. Learn more in :ref:`conn:watch() <conn-watch>`.
216+
217+
225218
.. _centralized_configuration_storage_publish_config_etcdctl:
226219

227220
Publishing configuration using etcdctl
228221
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
229222

230-
To publish a cluster's configuration using the ``etcdctl`` utility, use the ``put`` command:
223+
To publish a cluster's configuration to etcd using the ``etcdctl`` utility, use the ``put`` command:
231224

232225
.. code-block:: console
233226
@@ -246,7 +239,7 @@ To publish a cluster's configuration using the ``etcdctl`` utility, use the ``pu
246239
Configuring connection to a storage
247240
-----------------------------------
248241

249-
To use a centralized cluster's configuration, you need to provide connection settings in a local configuration file.
242+
To use a configuration from a centralized storage for your cluster, you need to provide connection settings in a local configuration file.
250243

251244

252245
.. _centralized_configuration_storage_connect_tarantool:

doc/reference/reference_lua/net_box.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ Below is a list of all ``net.box`` functions.
574574
In this case, the watcher remains registered.
575575
It is okay to discard the result of ``watch`` function if the watcher will never be unregistered.
576576

577-
**Example:**
577+
**Example 1:**
578578

579579
Server:
580580

@@ -601,6 +601,18 @@ Below is a list of all ``net.box`` functions.
601601
602602
w:unregister()
603603
604+
**Example 2:**
605+
606+
The ``net.box module`` provides the ability to monitor :ref:`updates of a configuration <centralized_configuration_storage_publish_config_tt>` stored in a Tarantool-based configuration storage by watching path or prefix changes.
607+
In the example below, :ref:`conn:watch() <conn-watch>` is used to monitor updates of a configuration stored by the ``/myapp/config/all`` path:
608+
609+
.. literalinclude:: /code_snippets/snippets/centralized_config/instances.enabled/config_storage/myapp.lua
610+
:language: lua
611+
:dedent:
612+
613+
You can find the full example here: `config_storage <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/centralized_config/instances.enabled/config_storage>`_.
614+
615+
604616
.. _net_box-is_async:
605617

606618
.. method:: request(... {is_async=...})

0 commit comments

Comments
 (0)