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/reference/configuration/configuration_reference.rst
+145
Original file line number
Diff line number
Diff line change
@@ -2877,6 +2877,116 @@ This section describes configuration parameters related to roles.
2877
2877
2878
2878
**Since:** :doc:`3.0.0 </release/3.0.0>`.
2879
2879
2880
+
Application roles of an instance.
2881
+
An application role is a Lua module that implement specific functions or logic.
2882
+
2883
+
To specify a role's configuration, use the :ref:`roles_cfg <configuration_reference_roles_cfg>` option.
2884
+
2885
+
There two types of application roles:
2886
+
2887
+
- Built-in roles. 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.
2888
+
- Custom roles. For example, you create a custom role to define a stored procedure or implement a supplementary service, such as an e-mail notifier or a replicator.
2889
+
2890
+
To create a custom role, you need to define the following methods and fields:
2891
+
2892
+
- ``validate()``
2893
+
2894
+
Validate a role's configuration.
2895
+
This method is called when the initial configuration is applied or the configuration is reloaded for the instance with this role.
2896
+
``validate()`` should throw an error if the validation fails.
2897
+
2898
+
- ``apply()``
2899
+
2900
+
Apply a role's configuration.
2901
+
This method is called when the initial configuration is applied or the configuration is reloaded for the instance with this role.
2902
+
``apply()`` should throw an error if the specified configuration can't be applied.
2903
+
2904
+
- ``stop()``
2905
+
2906
+
Stop a role.
2907
+
This method is called on configuration reload if the role is removed from ``roles`` for the given instance.
2908
+
``stop()`` should cancel all background fibers and clean up used resources.
2909
+
If these actions can't be performed, ``stop()`` should throw an error.
2910
+
2911
+
- (Optional) ``dependencies``
2912
+
2913
+
Define a role's dependencies as an array.
2914
+
The ``validate()`` and ``apply()`` methods are executed for related roles taking into account the dependencies.
2915
+
Suppose, there are three roles that depend on each other as follows:
2916
+
2917
+
.. code-block:: none
2918
+
2919
+
role1
2920
+
└─── role2
2921
+
└─── role3
2922
+
2923
+
In this case, ``validate()`` and ``apply()`` are executed in the following order:
2924
+
2925
+
.. code-block:: none
2926
+
2927
+
role3 -> role2 -> role1
2928
+
2929
+
2930
+
**Example: Built-in role**
2931
+
2932
+
The examples below show how to enable the ``roles.crud-router`` and ``roles.crud-storage`` roles provided by the `CRUD <https://github.com/tarantool/crud>`__ module on routers and storages, respectively:
You can find the full example here: `sharded_cluster_crud <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/sharding/instances.enabled/sharded_cluster_crud>`_.
2947
+
2948
+
**Example: Custom role**
2949
+
2950
+
The configuration below shows how to assign a custom ``greeter`` role to ``instance001`` and specify configuration for this role:
You can find the full example here: `application_role <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/config/instances.enabled/application_role>`_.
2965
+
2966
+
**Example: Role dependency**
2967
+
2968
+
The example below shows how to implement the ``greeter`` role:
You can find the full example here: `application_role_dependency <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/config/instances.enabled/application_role_dependency>`_.
2988
+
2989
+
2880
2990
|
2881
2991
|Type: array
2882
2992
|Default: nil
@@ -2889,6 +2999,41 @@ This section describes configuration parameters related to roles.
2889
2999
2890
3000
**Since:** :doc:`3.0.0 </release/3.0.0>`.
2891
3001
3002
+
Specify a role's configuration.
3003
+
This option accepts a role name as the key and a role's configuration as the value.
3004
+
3005
+
To specify the roles of an instance, use the :ref:`roles <configuration_reference_roles>` option.
3006
+
3007
+
**Example: Built-in role**
3008
+
3009
+
The example below shows how to enable and configure the ``roles.crud-router`` role provided by the `CRUD <https://github.com/tarantool/crud>`__ module:
You can find the full example here: `sharded_cluster_crud <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/sharding/instances.enabled/sharded_cluster_crud>`_.
3018
+
3019
+
**Example: Custom role**
3020
+
3021
+
The configuration below shows how to assign a custom ``greeter`` role to ``instance001`` and specify configuration for this role:
You can find the full example here: `sharded_cluster_crud <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/config/instances.enabled/application_role>`_.
0 commit comments