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/platform/app/app_roles.rst
+13-14Lines changed: 13 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,8 +27,6 @@ To learn how to enable and configure roles, see :ref:`configuration_application_
27
27
- A role of a replica set in regard to sharding. Learn more in :ref:`vshard_config_sharding_roles`.
28
28
29
29
30
-
31
-
32
30
.. _roles_create_custom_role_config:
33
31
34
32
Providing a role configuration
@@ -44,10 +42,15 @@ This example shows how to enable and configure the ``greeter`` role, which is im
44
42
:start-at: instance001
45
43
:dedent:
46
44
47
-
The role's configuration provided in ``roles_cfg`` can be accessed when :ref:`validating <roles_create_custom_role_validate>` and :ref:`applying <roles_create_custom_role_apply>` this configuration.
45
+
The role configuration provided in ``roles_cfg`` can be accessed when :ref:`validating <roles_create_custom_role_validate>` and :ref:`applying <roles_create_custom_role_apply>` this configuration.
48
46
49
-
Given that a role is a :ref:`Lua module <app_server-modules>`, a role's name is passed to ``require()`` to obtain the module.
50
-
When :ref:`developing an application <admin-instance_config-develop-app>`, you can place a file with a role's code next to a cluster's configuration file.
47
+
Tarantool includes the :ref:`experimental.config.utils.schema <config_utils_schema_module>`
48
+
built-in module that provides an for managing user-defined configurations
49
+
of applications (``app.cfg``) and roles (``roles_cfg``). The examples below show its
50
+
basic usage.
51
+
52
+
Given that a role is a :ref:`Lua module <app_server-modules>`, a role name is passed to ``require()`` to obtain the module.
53
+
When :ref:`developing an application <admin-instance_config-develop-app>`, you can place a file with the role code next to the cluster configuration file.
51
54
52
55
53
56
@@ -63,12 +66,12 @@ Overview
63
66
64
67
Creating a custom role includes the following steps:
65
68
66
-
1. Define a function that validates a role's configuration.
69
+
1. Define a function that validates a role configuration.
67
70
2. Define a function that applies a validated configuration.
68
71
3. Define a function that stops a role.
69
72
4. (Optional) Define roles from which this custom role depends on.
70
73
71
-
As a result, a role's module should return an object that has corresponding functions and fields specified:
74
+
As a result, a role module should return an object that has corresponding functions and fields specified:
72
75
73
76
.. code-block:: lua
74
77
@@ -86,14 +89,12 @@ The examples below show how to do this.
86
89
Code snippets shown in this section are included from the following application: `application_role_cfg <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/config/instances.enabled/application_role_cfg>`_.
87
90
88
91
89
-
90
-
91
92
.. _roles_create_custom_role_validate:
92
93
93
94
Validating a role configuration
94
95
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95
96
96
-
To validate a role's configuration, you need to define the :ref:`validate([cfg]) <roles_api_reference_validate>` function.
97
+
To validate a role configuration, you need to define the :ref:`validate([cfg]) <roles_api_reference_validate>` function.
97
98
The ``cfg`` argument provides access to the :ref:`role's configuration <roles_create_custom_role_config>` and check its validity.
98
99
99
100
In the example below, the ``validate()`` function is used to validate the ``greeting`` configuration value:
@@ -107,8 +108,6 @@ In the example below, the ``validate()`` function is used to validate the ``gree
107
108
If the configuration is not valid, ``validate()`` reports an unrecoverable error by throwing an error object.
108
109
109
110
110
-
111
-
112
111
.. _roles_create_custom_role_apply:
113
112
114
113
Applying a role configuration
@@ -117,7 +116,7 @@ Applying a role configuration
117
116
To apply the validated configuration, define the :ref:`apply([cfg]) <roles_api_reference_apply>` function.
118
117
As the ``validate()`` function, ``apply()`` provides access to a role's configuration using the ``cfg`` argument.
119
118
120
-
In the example below, the ``apply()`` function uses the :ref:`log <log-module>` module to write a role's configuration value to the log:
119
+
In the example below, the ``apply()`` function uses the :ref:`log <log-module>` module to write a value from the role configuration to the log:
0 commit comments