Skip to content

Conversation

georgiy-belyanin
Copy link
Member

This patchset focuses on updates in th config Lua module reference related to
config.storage.

The first patch adds documentation for the config.storage_client module.
The module allows one to connect to a remote config.storage cluster and
use it as a key-value storage.

The examples on connecting to a config.storage instance via iproto has
been changed to an example on connecting to multiple config.storage
instances using the config.storage client and interacting with a
config.storage cluster.

Closes #4734

The second patch adds config.storage TTL option allowing one to specify a
time-to-live for the key in config.storage.

Closes https://github.com/tarantool/enterprise_doc/issues/281

@github-actions github-actions bot temporarily deployed to branch-config-storage-client May 15, 2025 16:31 Destroyed
This patch adds documentation for the `config.storage_client` module.
The module allows one to connect to a remote config.storage cluster and
use it as a key-value storage.

The examples on connecting to a config.storage instance via iproto has
been changed to an example on connecting to multiple config.storage
instances using the config.storage client and interacting with a
config.storage cluster.

Closes #4734
This patch adds a time-to-live (TTL) option to `config.storage` API
methods. This option allows one to put keys that will expire when the
passed time passes.

Closes tarantool/enterprise_doc#281
:param string value: a value to put
:param table opts: a table containing the following optional fields:

* ``ttl`` (since :doc:`3.2.0 </release/3.2.0>`, default: unset): time-to-live in seconds, if nil or not set the key won't expire, may issue an error if set on config.storage running old schema, see :ref:`config.storage.info <config_storage_api_reference_info>`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIR, we discussed a lot the following corner cases:

  • If a key exists and has no TTL, what put of this key with TTL do?
  • Vice versa: if the key exists and has TTL, what put of this key without TTL do?
  • Next, if a key has TTL that expires at time T and we attempt to put this key with a TTL that expires at time T1 < T, whether the expire occurs on T1 or T? How about T2 > T?

I would like if the API documentation would describe a behavior in these scenarios.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed the doc as follows.

--- a/doc/reference/reference_lua/config.rst
+++ b/doc/reference/reference_lua/config.rst
@@ -403,7 +403,7 @@ The ``config.storage`` API allows you to interact with a Tarantool-based :ref:`c
     :param string value: a value to put
     :param table opts:   a table containing the following optional fields:

-                            *   ``ttl`` (since :doc:`3.2.0 </release/3.2.0>`, default: unset): time-to-live in seconds, if nil or not set the key won't expire, may issue an error if set on config.storage running old schema, see :ref:`config.storage.info <config_storage_api_reference_info>`.
+                            *   ``ttl`` (since :doc:`3.2.0 </release/3.2.0>`, default: unset): time-to-live in seconds. If nil or not set the key won't expire. If the path is already present its deadline is calculated for the new time-to-live value no matter if it has been unset, later, or earlier than the new one. The option may issue an error if set on config.storage running old schema, see :ref:`config.storage.info <config_storage_api_reference_info>`.


     :return:    a table containing the following fields:

Comment on lines +644 to +652
:return: a table containing the following fields:

* ``data``: a table containing the information about the value:

* ``path``: a path
* ``mod_revision``: the last revision at which this value was modified
* ``value:``: a value

* ``revision``: a revision after performing the operation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, it is not very clear from this description, whether data contains the {path = <...>, mod_revision = <...>, value = <...>} mapping or an array of them. Since the call suport both point and prefix requests, I guess that it is either an array or a mapping of mappings. Anyway, I think that it would be nice to make it clear.

This is not really to this PR, because the description is the same as for the server API. Feel free to ignore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to ignore it in this patch.

Comment on lines +615 to +616
:param string path: a path to put the value by
:param string value: a value to put
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know why, but it seems the rendering fails here:

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And in other places too.

Copy link
Contributor

@Totktonada Totktonada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on it!

Copy link
Contributor

@AArdeev AArdeev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо потом на пересобранное посмотреть, отработают ли ссылки на return tyoe table

- ``timeout`` specifies the interval (in seconds) to perform the status check of a configuration storage.
- ``reconnect_after`` specifies how much time to wait (in seconds) before reconnecting to a configuration storage.

You might use :ref:`config.storage_client <config_storage_client_api_reference>` API for connecting and controlling a remote config.storage cluster.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the :ref:config.storage_client <config_storage_client_api_reference> API to connect to and control a remote config.storage cluster.


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.

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. ``config.storage_client`` allows to connect to such storages and to interact with them from other Tarantool instances.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. config.storage_client allows connecting to such storages and interacting with them from other Tarantool instances.

- Connect to a remote config.storage cluster

* - :ref:`<config.storage client>:put() <config_storage_client_api_reference_put>`
- Put a value by the specified path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Store a value at the specified path

- Put a value by the specified path

* - :ref:`<config.storage client>:get() <config_storage_client_api_reference_get>`
- Get a value stored by the specified path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get a value stored at the specified path

- Get a value stored by the specified path

* - :ref:`<config.storage client>:delete() <config_storage_client_api_reference_delete>`
- Delete a value stored by the specified path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete a value stored at the specified path


.. function:: <config.storage client>:on_disconnect(func)

Set a trigger for execution when the established connection to a config.storage cluster instance is closed. This also includes the cases when the config.storage client loses connection to a specific instance but automatically re-establishes it to another available one. Execution stops after a config.storage client is explicitly closed, or once the Lua garbage collector removes it. Calling this method replaces an old disconnect trigger with a new one if set.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set a trigger for execution when the established connection to a config.storage cluster instance is closed. This also includes cases when
the config.storage client loses connection to a specific instance but automatically re-establishes it to another available one.
Execution stops after the config.storage client is explicitly closed, or once the Lua garbage collector removes it. Calling this method replaces any existing disconnect trigger with a new one if set.


.. function:: <config.storage client>:watch(path_or_event_key, func)

Subscribe to config.storage events broadcast. You might use one of the following events.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subscribe to the config.storage events broadcast. The following events are available:

Comment on lines +886 to +887
* ``info`` is an event corresponding to the update on the client information.
* ``/path/to/key`` or ``/prefix/to/watch/`` is an event that corresponds to the updates of the specific key or of multiple keys having the specified prefix.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • info corresponds to the update on the client information.
  • /path/to/key or /prefix/to/watch/ corresponds to the updates of the specific key or of multiple keys having the specified prefix.


To read more about watchers, see the :ref:`Functions for watchers <box-watchers>` section.

The method has the same syntax as :ref:`box.watch() <box-watch>` and :ref:`conn:watch() <conn-watch>` functions. In fact, the call ``<config.storage client>:watch('<key>', f)`` internally subscribes to ``config.storage.<key>`` or to ``config.storage:<path>`` event broadcast through :ref:`IPROTO <box_protocol-id>`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method has the same syntax as :ref:box.watch() <box-watch> and :ref:conn:watch() <conn-watch> functions. In fact, the
<config.storage client>:watch('<key>', f) call internally subscribes to config.storage.<key> or config.storage:<path> event
broadcast through :ref:IPROTO <box_protocol-id>.

Comment on lines +906 to +908
Keep in mind that garbage collection of a watcher handle doesn't lead to the watcher's destruction.
In this case, the watcher remains registered.
It is okay to discard the result of ``watch`` function if the watcher will never be unregistered.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Garbage collection of a watcher handle does not lead to the watcher's destruction.
In this case, the watcher remains registered.

You can discard the result of the ``watch`` function if the watcher is not going to be unregistered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants