Skip to content

Commit 922d99e

Browse files
committed
Roles: cosmetics
1 parent 1dd9de0 commit 922d99e

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

doc/concepts/configuration.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Enabling and configuring roles
184184
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
185185

186186
An application role is a Lua module that implements specific functions or logic.
187-
You can enable or turn off a specific role for certain instances in a configuration without restarting these instances.
187+
You can enable or turn off a particular role for certain instances in a configuration without restarting these instances.
188188

189189
This section describes how to enable and configure roles.
190190
To learn how to develop custom roles, see :ref:`application_roles`.
@@ -240,9 +240,9 @@ Roles and configuration scopes
240240
******************************
241241

242242
As the most of configuration options, roles and their configurations can be defined at :ref:`different levels <configuration_scopes>`.
243-
Given that the ``roles`` option has the ``array`` type and ``roles_cfg`` has the ``map`` type, there are some specifics when applying the configuration:
243+
Given that the ``roles`` option has the ``array`` type and ``roles_cfg`` has the ``map`` type, there are some specifics of applying the configuration:
244244

245-
- For ``roles``, an instance's role takes precedence over roles defined at another levels.
245+
- For ``roles``, an instance's role takes precedence over roles defined at another level.
246246
In the example below, ``instance001`` has only ``role3``:
247247

248248
.. code-block:: yaml
@@ -258,7 +258,7 @@ Given that the ``roles`` option has the ``array`` type and ``roles_cfg`` has the
258258

259259
- For ``roles_cfg``, the following rules are applied:
260260

261-
- If a configuration for the same role is provided at different levels, an instance configuration takes precedence over configuration defined at another levels.
261+
- If a configuration for the same role is provided at different levels, an instance configuration takes precedence over the configuration defined at another level.
262262
In the example below, ``role1.greeting`` is ``'Hi'``:
263263

264264
.. code-block:: yaml
@@ -275,7 +275,7 @@ Given that the ``roles`` option has the ``array`` type and ``roles_cfg`` has the
275275
role1:
276276
greeting: 'Hi'
277277
278-
- If configurations for different roles are provided at different levels, both configurations are applied at the instance level.
278+
- If the configurations for different roles are provided at different levels, both configurations are applied at the instance level.
279279
In the example below, ``instance001`` has ``role1.greeting`` set to ``'Hi'`` and ``role2.farewell`` set to ``'Bye'``:
280280

281281
.. code-block:: yaml

doc/how-to/app/app_roles.rst

+24-24
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Application roles
44
=================
55

66
An application role is a Lua module that implements specific functions or logic.
7-
You can enable or turn off a specific role for certain instances in a :ref:`configuration <configuration>` without restarting these instances.
7+
You can enable or turn off a particular role for certain instances in a :ref:`configuration <configuration>` without restarting these instances.
88
A role is run when a configuration is loaded or reloaded.
99

1010
Roles can be divided into the following groups:
@@ -14,7 +14,7 @@ Roles can be divided into the following groups:
1414
- Roles provided by third-party Lua modules.
1515
For example, the `CRUD <https://github.com/tarantool/crud>`__ module provides the ``roles.crud-storage`` and ``roles.crud-router`` roles that enable CRUD operations in a sharded cluster.
1616
- Custom roles that are developed as a part of a cluster application.
17-
For example, you create a custom role to define a stored procedure or implement a supplementary service, such as an email notifier or a replicator.
17+
For example, you can create a custom role to define a stored procedure or implement a supplementary service, such as an email notifier or a replicator.
1818

1919
This section describes how to develop custom roles.
2020
To learn how to enable and configure roles, see :ref:`configuration_application_roles`.
@@ -61,12 +61,12 @@ Creating a custom role
6161
Overview
6262
~~~~~~~~
6363

64-
The main steps of creating a custom role might include the following steps:
64+
Creating a custom role includes the following steps:
6565

6666
1. Define a function that validates a role's configuration.
6767
2. Define a function that applies a validated configuration.
6868
3. Define a function that stops a role.
69-
4. (Optional) Define roles from which a custom role depends on.
69+
4. (Optional) Define roles from which this custom role depends on.
7070

7171
As a result, a role's module should return an object that has corresponding functions and fields specified:
7272

@@ -104,7 +104,7 @@ In the example below, the ``validate()`` function is used to validate the ``gree
104104
:end-before: local function apply
105105
:dedent:
106106

107-
If the configuration is not valid, ``validate`` reports an unrecoverable error by throwing an error object.
107+
If the configuration is not valid, ``validate()`` reports an unrecoverable error by throwing an error object.
108108

109109

110110

@@ -114,8 +114,8 @@ If the configuration is not valid, ``validate`` reports an unrecoverable error b
114114
Applying a role configuration
115115
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116116

117-
To apply a validated configuration, define the :ref:`apply([cfg]) <roles_api_reference_apply>` function.
118-
As the ``validate()`` function, ``apply()`` also provides access to a role's configuration using the ``cfg`` argument.
117+
To apply the validated configuration, define the :ref:`apply([cfg]) <roles_api_reference_apply>` function.
118+
As the ``validate()`` function, ``apply()`` provides access to a role's configuration using the ``cfg`` argument.
119119

120120
In the example below, the ``apply()`` function uses the :ref:`log <log-module>` module to write a role's configuration value to the log:
121121

@@ -225,50 +225,50 @@ You can check an instance state by subscribing to the ``box.status`` event using
225225
Roles life cycle
226226
----------------
227227

228-
Roles' life cycle includes the stages described below.
228+
A role’s life cycle includes the stages described below.
229229

230230
.. _roles_life_cycle_loading_roles:
231231

232232
1) *Loading roles*
233233

234-
On each run, all roles are loaded in the order they are specified in a :ref:`configuration <roles_create_custom_role_config>`.
235-
This stage is in effect when a role is enabled or an instance with this role is restarted.
234+
On each run, all roles are loaded in the order they are specified in the :ref:`configuration <roles_create_custom_role_config>`.
235+
This stage takes effect when a role is enabled or an instance with this role is restarted.
236236
At this stage, a role executes the :ref:`initialization code <roles_create_custom_role_init>`.
237237

238238
A role cannot be started if it has :ref:`dependencies <roles_create_custom_role_dependencies>` that are not specified in a configuration.
239239

240240
.. NOTE::
241241

242-
Dependencies do not affect the order of how roles are loaded.
243-
At the same time, the ``validate()``, ``apply()``, and ``stop()`` functions are executed taking into account the dependencies.
242+
Dependencies do not affect the order in which roles are loaded.
243+
However, the ``validate()``, ``apply()``, and ``stop()`` functions are executed taking dependencies into account.
244244
Learn more in :ref:`roles_life_cycle_dependencies_specifics`.
245245

246246

247247
.. _roles_life_cycle_stopping_roles:
248248

249249
2) *Stopping roles*
250250

251-
This stage is in effect on configuration reload when a role is removed from configuration for the given instance.
251+
This stage takes effect during a configuration reload when a role is removed from the configuration for a given instance.
252252
Note that all ``stop()`` calls are performed before any ``validate()`` or ``apply()`` calls.
253-
This means that old roles are stopped first and only then new roles are started.
253+
This means that old roles are stopped first, and only then new roles are started.
254254

255255
.. _roles_life_cycle_validating_role_config:
256256

257-
3) *Validating roles' configurations*
257+
3) *Validating a role's configurations*
258258

259-
At this stage, a configuration for each role is validated using the corresponding :ref:`validate() <roles_api_reference_validate>` function in the same order as they specified in a configuration.
259+
At this stage, a configuration for each role is validated using the corresponding :ref:`validate() <roles_api_reference_validate>` function in the same order in which they are specified in the configuration.
260260

261261
.. _roles_life_cycle_applying_role_config:
262262

263-
4) *Applying roles' configurations*
263+
4) *Applying a role's configurations*
264264

265-
At this stage, a configuration for each role is applied using the corresponding :ref:`apply() <roles_api_reference_apply>` function in the same order as they specified in a configuration.
265+
At this stage, a configuration for each role is applied using the corresponding :ref:`apply() <roles_api_reference_apply>` function in the same order in which they are specified in the configuration.
266266

267267

268268
All role's functions report an unrecoverable error by throwing an error object.
269269
If an error is thrown in any phase, applying a configuration is stopped.
270270
If starting or stopping a role throws an error, no roles are stopped or started afterward.
271-
An error is catched and shown in :ref:`config:info() <config_api_reference_info>` in the ``alerts`` section.
271+
An error is caught and shown in :ref:`config:info() <config_api_reference_info>` in the ``alerts`` section.
272272

273273

274274
.. _roles_life_cycle_dependencies_specifics:
@@ -285,7 +285,7 @@ Suppose, there are two independent roles (``role1``, ``role2``) and three roles
285285
└─── role4
286286
└─── role5
287287
288-
The roles are enable in a configuration as follows:
288+
The roles are enabled in a configuration as follows:
289289

290290
.. code-block:: yaml
291291
@@ -298,13 +298,13 @@ In this case, ``validate()`` and ``apply()`` for these roles are executed in the
298298
role1 -> role2 -> role5 -> role4 -> role3
299299
300300
Roles removed from a configuration are stopped in the order reversed to the order they are specified in a configuration, taking into account the dependencies.
301-
If all roles except ``role1`` are removed from the configuration above, ...
301+
Suppose, all roles except ``role1`` are removed from the configuration above:
302302

303303
.. code-block:: yaml
304304
305305
roles: [ role1 ]
306306
307-
... ``stop()`` functions for removed roles are executed in the following order:
307+
After reloading a configuration, ``stop()`` functions for the removed roles are executed in the following order:
308308

309309
.. code-block:: none
310310
@@ -326,7 +326,7 @@ The example below shows how to enable the custom ``greeter`` role for ``instance
326326
:end-at: greeter
327327
:dedent:
328328

329-
You can define the ``validate()``, ``apply()``, and ``stop()`` functions in the role's code as follows:
329+
The implementation of this role looks as follows:
330330

331331
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/application_role/greeter.lua
332332
:language: lua
@@ -349,7 +349,7 @@ The example below shows how to enable the custom ``greeter`` role for ``instance
349349
:end-at: greeting
350350
:dedent:
351351

352-
You can define the ``validate()``, ``apply()``, and ``stop()`` functions in the role's code as follows:
352+
The implementation of this role looks as follows:
353353

354354
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/application_role_cfg/greeter.lua
355355
:language: lua

0 commit comments

Comments
 (0)