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
@@ -2877,6 +2878,116 @@ This section describes configuration parameters related to roles.
2877
2878
2878
2879
**Since:** :doc:`3.0.0 </release/3.0.0>`.
2879
2880
2881
+
Specify the roles of an instance.
2882
+
To specify a role's configuration, use the :ref:`roles_cfg <configuration_reference_roles_cfg>` option.
2883
+
2884
+
There are two types of application roles:
2885
+
2886
+
- 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.
2887
+
- 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.
2888
+
2889
+
To create a custom role, you need to define the following methods and fields:
2890
+
2891
+
- ``validate()``
2892
+
2893
+
Validate a role's configuration.
2894
+
This method is called when the initial configuration is applied or the configuration is reloaded for the instance with this role.
2895
+
``validate()`` should throw an error if the validation fails.
2896
+
2897
+
- ``apply()``
2898
+
2899
+
Apply a role's configuration.
2900
+
This method is called when the initial configuration is applied or the configuration is reloaded for the instance with this role.
2901
+
``apply()`` should throw an error if the specified configuration can't be applied.
2902
+
2903
+
- ``stop()``
2904
+
2905
+
Stop a role.
2906
+
This method is called on configuration reload if the role is removed from ``roles`` for the given instance.
2907
+
``stop()`` should cancel all background fibers and clean up used resources.
2908
+
If these actions can't be performed, ``stop()`` should throw an error.
2909
+
2910
+
- (Optional) ``dependencies``
2911
+
2912
+
Define a role's dependencies as an array.
2913
+
The ``validate()`` and ``apply()`` methods are executed for related roles taking into account the dependencies.
2914
+
Suppose, there are three roles that depend on each other as follows:
2915
+
2916
+
.. code-block:: none
2917
+
2918
+
role1
2919
+
└─── role2
2920
+
└─── role3
2921
+
2922
+
In this case, ``validate()`` and ``apply()`` are executed in the following order:
2923
+
2924
+
.. code-block:: none
2925
+
2926
+
role3 -> role2 -> role1
2927
+
2928
+
2929
+
**Example: Built-in role**
2930
+
2931
+
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>`_.
2946
+
2947
+
**Example: Custom role**
2948
+
2949
+
The configuration below shows how to assign the custom ``greeter`` role to ``instance001`` and specify the 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>`_.
2964
+
2965
+
**Example: Role dependency**
2966
+
2967
+
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>`_.
2989
+
2990
+
2880
2991
|
2881
2992
|Type: array
2882
2993
|Default: nil
@@ -2889,6 +3000,40 @@ This section describes configuration parameters related to roles.
2889
3000
2890
3001
**Since:** :doc:`3.0.0 </release/3.0.0>`.
2891
3002
3003
+
Specify a role's configuration.
3004
+
This option accepts a role name as the key and a role's configuration as the value.
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 the custom ``greeter`` role to ``instance001`` and specify the 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>`_.
0 commit comments