-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config: introduce roles #9087
Merged
Merged
config: introduce roles #9087
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p7nov
reviewed
Sep 4, 2023
p7nov
approved these changes
Sep 4, 2023
Totktonada
reviewed
Sep 4, 2023
Totktonada
reviewed
Sep 4, 2023
Totktonada
reviewed
Sep 4, 2023
Totktonada
reviewed
Sep 4, 2023
ImeevMA
force-pushed
the
imeevma/gh-9078-roles
branch
from
September 5, 2023 15:48
1a61576
to
36099ba
Compare
Totktonada
reviewed
Sep 6, 2023
Totktonada
reviewed
Sep 6, 2023
Totktonada
reviewed
Sep 6, 2023
Totktonada
reviewed
Sep 6, 2023
Totktonada
reviewed
Sep 6, 2023
Totktonada
reviewed
Sep 6, 2023
Totktonada
reviewed
Sep 6, 2023
Totktonada
reviewed
Sep 6, 2023
ImeevMA
force-pushed
the
imeevma/gh-9078-roles
branch
from
September 7, 2023 20:30
36099ba
to
dc99987
Compare
Totktonada
reviewed
Sep 8, 2023
Totktonada
approved these changes
Sep 8, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the patch!
I'm OK in general, but, please consider a few remaining small comments above. (Let's add the full-ci
label right after the fix.)
ImeevMA
force-pushed
the
imeevma/gh-9078-roles
branch
from
September 8, 2023 07:34
dc99987
to
9f2841d
Compare
This patch introduces initial support for roles. Dependencies are not currently supported for roles. Part of tarantool#9078 @TarantoolBot document Title: Roles Two new options have been added: "roles" and "roles_cfg". The first one is an array and the second one is a map. Each of these can be defined per instance, replica set, group, and globally. As with almost all other options, with the exception of those defined as 'map', the 'roles' option for the lower scope will replace the roles for the higher scope. Value roles_cfg however defined as "map", so it will be merged. The "roles" option defines the roles for each instance. A role is a program that runs when a configuration is loaded or reloaded. If a role is defined more than once on an instance, it will still only be run once. Three functions must be defined in the role: validate(), apply() and stop(). Each of these functions should throw an error if it occurs. The "roles_cfg" option specifies the configuration for each role. In this option, the role name is the key and the role configuration is the value. On each run, all roles will be loaded (if necessary) in the order in which they were specified; the configuration for each role will then be validated using the corresponding validate() function in the same order; and then they will all be run with apply() function in the same order. If some roles have been removed from the instance, they will be stopped in reverse order using the stop() function. Example of a role structure: ``` local M = {} -- Validates configuration of the role. -- -- Called on initial configuration apply at startup and on -- configuration reload if the role is enabled for the given instance. -- -- The cfg argument may have arbitrary user provided value, -- including nil. -- -- Must raise an error if the validation fail. function M.validate(cfg) -- <...> end -- Applies the given configuration of the role. -- -- Called on initial configuration apply at startup and on -- configuration reload if the role is enabled for the given instance. -- -- The cfg argument may have arbitrary user provided value, -- including nil. -- -- Must raise an error if the given configuration can't be applied. function M.apply(cfg) -- <...> end -- Stops the role. -- -- Called on configuration reload if the role was enabled before -- and removed now from the list of roles of the given instance. -- -- Should cancel all background fibers and clean up hold -- resources. -- -- Must raise an error if this action can't be performed. function M.stop() -- <...> end return M ```
ImeevMA
force-pushed
the
imeevma/gh-9078-roles
branch
from
September 8, 2023 08:08
9f2841d
to
81f4d6d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch introduces initial support for roles. Dependencies are not
currently supported for roles.
Part of #9078
@TarantoolBot document
Title: Roles
Two new options have been added: "roles" and "roles_cfg". The first one
is an array and the second one is a map. Each of these can be defined
per instance, replica set, group, and globally. As with almost all other
options, with the exception of those defined as 'map', the 'roles'
option for the lower scope will replace the roles for the higher scope.
Value roles_cfg however defined as "map", so it will be merged.
The "roles" option defines the roles for each instance. A role is a
program that runs when a configuration is loaded or reloaded. If a role
is defined more than once on an instance, it will still only be run
once. Three functions must be defined in the role: validate(), apply()
and stop(). Each of these functions should throw an error if it occurs.
The "roles_cfg" option specifies the configuration for each role. In
this option, the role name is the key and the role configuration is the
value.
On each run, all roles will be loaded (if necessary) in the order in
which they were specified; the configuration for each role will then be
validated using the corresponding validate() function in the same order;
and then they will all be run with apply() function in the same order.
If some roles have been removed from the instance, they will be stopped
in reverse order using the stop() function.
Example of a role structure: