From 821385de12337439900e424d0a83df86b7b06035 Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Fri, 4 Jul 2025 17:00:02 +0300 Subject: [PATCH 01/16] Adds description of the on_event callback to custom application roles Added general info about custom roles as an intro to the section' Fixes #4666 --- doc/platform/app/app_roles.rst | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index 4d60a298c..5700908f5 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -64,6 +64,30 @@ Creating a custom role Overview ~~~~~~~~ +A custom application role is an object which implements custom functions or logic adding to Tarantool's built-in roles and roles provided by third-party Lua modules. +For example, a logging role can be created to add logging functionality on top of the built-in one. + +Since version :doc:`3.4.0 `, you can define an ``on_event`` callback for custom roles. The ``on_event`` callback is called +every time a ``box.status`` system event is broadcasted, or after the ``apply`` action of the configuration update is finished. +If multiple custom roles have the ``on_event`` callback defined, these callbacks are called one after another in the order +defined by roles dependencies. +The ``on_event`` callback provides 3 arguments, when it is called: + +- ``config``, which is the configuration of the role; +- ``key``, which reflects the trigger event: + - ``config.apply`` if the callback was triggered by a configuration update; + - ``box.status`` if it was triggered by the ``box.status`` system event. +- ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. + If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. + +.. NOTE:: + + - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration + process. Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. + - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged with ``error`` level + and the series execution continues. + + Creating a custom role includes the following steps: #. (Optional) Define the role configuration schema. @@ -71,6 +95,7 @@ Creating a custom role includes the following steps: #. Define a function that applies a validated configuration. #. Define a function that stops a role. #. (Optional) Define roles from which this custom role depends on. +#. (Optional) Define the ``on_event`` callback function. As a result, a role module should return an object that has corresponding functions and fields specified: @@ -81,6 +106,13 @@ As a result, a role module should return an object that has corresponding functi apply = function() -- ... -- end, stop = function() -- ... -- end, dependencies = { -- ... -- }, + on_event = function(config, key, value) + local log = require('log') + + log.info('roles_cfg.my_role.foo: ' .. config.foo) + log.info('on_event is triggered by ' .. key) + log.info('is_ro: ' .. value.is_ro) + end, } The examples below show how to do this. From e1b6d32064463a28687329bda1e3cb126e7eaf6b Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Fri, 4 Jul 2025 17:13:05 +0300 Subject: [PATCH 02/16] Fixes syntax --- doc/platform/app/app_roles.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index 5700908f5..3a19cd3ee 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -74,16 +74,17 @@ defined by roles dependencies. The ``on_event`` callback provides 3 arguments, when it is called: - ``config``, which is the configuration of the role; -- ``key``, which reflects the trigger event: +- ``key``, which reflects the trigger event: - ``config.apply`` if the callback was triggered by a configuration update; - ``box.status`` if it was triggered by the ``box.status`` system event. -- ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. +- ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. .. NOTE:: - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. + - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged with ``error`` level and the series execution continues. From f6586c4f9a7bb584629e7001a0d2d7eb06497813 Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Fri, 4 Jul 2025 17:22:03 +0300 Subject: [PATCH 03/16] Fixes syntax --- doc/platform/app/app_roles.rst | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index 3a19cd3ee..12da94033 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -73,11 +73,13 @@ If multiple custom roles have the ``on_event`` callback defined, these callbacks defined by roles dependencies. The ``on_event`` callback provides 3 arguments, when it is called: -- ``config``, which is the configuration of the role; -- ``key``, which reflects the trigger event: - - ``config.apply`` if the callback was triggered by a configuration update; - - ``box.status`` if it was triggered by the ``box.status`` system event. -- ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. + - ``config``, which is the configuration of the role; + + - ``key``, which reflects the trigger event: + + - ``config.apply`` if the callback was triggered by a configuration update; + - ``box.status`` if it was triggered by the ``box.status`` system event. + - ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. .. NOTE:: @@ -110,10 +112,10 @@ As a result, a role module should return an object that has corresponding functi on_event = function(config, key, value) local log = require('log') - log.info('roles_cfg.my_role.foo: ' .. config.foo) - log.info('on_event is triggered by ' .. key) - log.info('is_ro: ' .. value.is_ro) - end, + log.info('roles_cfg.my_role.foo: ' .. config.foo) + log.info('on_event is triggered by ' .. key) + log.info('is_ro: ' .. value.is_ro) + end, } The examples below show how to do this. From 37b49371de6505a063d513871951ee5dacb2b365 Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Fri, 4 Jul 2025 17:24:28 +0300 Subject: [PATCH 04/16] Fixes syntax --- doc/platform/app/app_roles.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index 12da94033..5764771a6 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -90,7 +90,6 @@ The ``on_event`` callback provides 3 arguments, when it is called: - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged with ``error`` level and the series execution continues. - Creating a custom role includes the following steps: #. (Optional) Define the role configuration schema. From 6b8846371f6d9ff14cdccdb8240006306a195512 Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Fri, 4 Jul 2025 17:34:44 +0300 Subject: [PATCH 05/16] Fixes syntax --- doc/platform/app/app_roles.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index 5764771a6..71bf54004 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -84,8 +84,8 @@ The ``on_event`` callback provides 3 arguments, when it is called: .. NOTE:: - - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration - process. Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. + - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. + Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged with ``error`` level and the series execution continues. From 823b33ed13fe88a1b836186ac69f1e770eac4de0 Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Fri, 4 Jul 2025 17:46:13 +0300 Subject: [PATCH 06/16] Fix lines --- doc/platform/app/app_roles.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index 71bf54004..958092b94 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -79,16 +79,16 @@ The ``on_event`` callback provides 3 arguments, when it is called: - ``config.apply`` if the callback was triggered by a configuration update; - ``box.status`` if it was triggered by the ``box.status`` system event. - - ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. + - ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. .. NOTE:: - - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. + - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. - - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged with ``error`` level - and the series execution continues. + - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged with + the ``error`` level and the series execution continues. Creating a custom role includes the following steps: From bf6017ea24f25f4421b66b54388a19a5f278e375 Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Fri, 4 Jul 2025 18:44:53 +0300 Subject: [PATCH 07/16] fix lines --- doc/platform/app/app_roles.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index 958092b94..2502f5c19 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -71,6 +71,7 @@ Since version :doc:`3.4.0 `, you can define an ``on_event`` call every time a ``box.status`` system event is broadcasted, or after the ``apply`` action of the configuration update is finished. If multiple custom roles have the ``on_event`` callback defined, these callbacks are called one after another in the order defined by roles dependencies. + The ``on_event`` callback provides 3 arguments, when it is called: - ``config``, which is the configuration of the role; From baf94cc5fc45e5ed42270b99b23e7c735ceebd7e Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Fri, 4 Jul 2025 18:59:16 +0300 Subject: [PATCH 08/16] Fix lines --- doc/platform/app/app_roles.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index 2502f5c19..625223da0 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -74,12 +74,12 @@ defined by roles dependencies. The ``on_event`` callback provides 3 arguments, when it is called: - - ``config``, which is the configuration of the role; + - ``config``, which contains the configuration of the role; - ``key``, which reflects the trigger event: - - - ``config.apply`` if the callback was triggered by a configuration update; + - ``config.apply`` if the callback was triggered by a configuration update; - ``box.status`` if it was triggered by the ``box.status`` system event. + - ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. From b093a539e0c1282ba74b09c1c8b1829a28e15f9a Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Mon, 7 Jul 2025 08:18:12 +0300 Subject: [PATCH 09/16] syntax --- doc/platform/app/app_roles.rst | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index 625223da0..6fae3636a 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -80,16 +80,13 @@ The ``on_event`` callback provides 3 arguments, when it is called: - ``config.apply`` if the callback was triggered by a configuration update; - ``box.status`` if it was triggered by the ``box.status`` system event. - - ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. - If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. + - ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. .. NOTE:: - - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. - Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. + - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. - - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged with - the ``error`` level and the series execution continues. + - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged with the ``error`` level and the series execution continues. Creating a custom role includes the following steps: From 75c4c33147229eadd35cd47f4b1de574fd62c391 Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Mon, 7 Jul 2025 09:16:07 +0300 Subject: [PATCH 10/16] syntax --- doc/platform/app/app_roles.rst | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index 6fae3636a..950959d21 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -74,19 +74,21 @@ defined by roles dependencies. The ``on_event`` callback provides 3 arguments, when it is called: - - ``config``, which contains the configuration of the role; +- ``config``, which contains the configuration of the role; - - ``key``, which reflects the trigger event: - - ``config.apply`` if the callback was triggered by a configuration update; - - ``box.status`` if it was triggered by the ``box.status`` system event. - - - ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. +- ``key``, which reflects the trigger event: + - ``config.apply`` if the callback was triggered by a configuration update; + - ``box.status`` if it was triggered by the ``box.status`` system event. +- ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. +If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. .. NOTE:: - - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. + - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. + Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. - - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged with the ``error`` level and the series execution continues. + - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged + with the ``error`` level and the series execution continues. Creating a custom role includes the following steps: From e09daeb36fc8610c81a9fc0b4701019615122432 Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Mon, 7 Jul 2025 09:37:17 +0300 Subject: [PATCH 11/16] syntax --- doc/platform/app/app_roles.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index 950959d21..1e1141f07 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -77,8 +77,11 @@ The ``on_event`` callback provides 3 arguments, when it is called: - ``config``, which contains the configuration of the role; - ``key``, which reflects the trigger event: + - ``config.apply`` if the callback was triggered by a configuration update; + - ``box.status`` if it was triggered by the ``box.status`` system event. + - ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. From 1a7b0885d79f9d7ad40487a9a3e546fea26d9da7 Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Mon, 7 Jul 2025 10:30:32 +0300 Subject: [PATCH 12/16] syntax --- doc/platform/app/app_roles.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index 1e1141f07..a9f121845 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -72,11 +72,11 @@ every time a ``box.status`` system event is broadcasted, or after the ``apply`` If multiple custom roles have the ``on_event`` callback defined, these callbacks are called one after another in the order defined by roles dependencies. -The ``on_event`` callback provides 3 arguments, when it is called: +The ``on_event`` callback returns 3 arguments, when it is called: - ``config``, which contains the configuration of the role; -- ``key``, which reflects the trigger event: +- ``key``, which reflects the trigger event and is set to: - ``config.apply`` if the callback was triggered by a configuration update; @@ -87,11 +87,11 @@ If the callback is triggered by a configuration update, the ``value`` shows the .. NOTE:: - - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. - Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. + - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. + Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. - - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged - with the ``error`` level and the series execution continues. + - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, + it is logged with the ``error`` level and the series execution continues. Creating a custom role includes the following steps: From 6743a6c05545f60c6069abbd46603d39e9cab75e Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Mon, 7 Jul 2025 10:49:28 +0300 Subject: [PATCH 13/16] syntax --- doc/platform/app/app_roles.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index a9f121845..db21400f5 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -81,17 +81,16 @@ The ``on_event`` callback returns 3 arguments, when it is called: - ``config.apply`` if the callback was triggered by a configuration update; - ``box.status`` if it was triggered by the ``box.status`` system event. - - ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. .. NOTE:: - - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. - Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. +- All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. +Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. - - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, - it is logged with the ``error`` level and the series execution continues. +- All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, +it is logged with the ``error`` level and the series execution continues. Creating a custom role includes the following steps: From 1507451765054c1815df94d04f3bb9d87e7be2ab Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Mon, 7 Jul 2025 12:29:59 +0300 Subject: [PATCH 14/16] syntax --- doc/platform/app/app_roles.rst | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index db21400f5..8e6033314 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -81,16 +81,13 @@ The ``on_event`` callback returns 3 arguments, when it is called: - ``config.apply`` if the callback was triggered by a configuration update; - ``box.status`` if it was triggered by the ``box.status`` system event. -- ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. -If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. +- ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. .. NOTE:: -- All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. -Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. + - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. -- All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, -it is logged with the ``error`` level and the series execution continues. + - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged with the ``error`` level and the series execution continues. Creating a custom role includes the following steps: From 7b0a985453b9219d093fb823b4093acf9191e438 Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Mon, 7 Jul 2025 13:36:44 +0300 Subject: [PATCH 15/16] syntax --- doc/platform/app/app_roles.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index 8e6033314..f6757cb94 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -81,13 +81,16 @@ The ``on_event`` callback returns 3 arguments, when it is called: - ``config.apply`` if the callback was triggered by a configuration update; - ``box.status`` if it was triggered by the ``box.status`` system event. -- ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. +- ``value``, which shows and logs the information about the instance status as in the trigger ``box.status`` system event. + If the callback is triggered by a configuration update, the ``value`` shows the information of the most recent ``box.status`` system event. .. NOTE:: - - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. + - All ``on_event`` callbacks with the ``config.apply`` key are executed as a part of the configuration process. + Process statuses ``ready`` or ``check_warnings`` are reached only after all such ``on_event`` callbacks are done. - - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged with the ``error`` level and the series execution continues. + - All ``on_event`` callbacks are executed inside of a ``pcall``. If an error is raised for a callback, it is logged + with the ``error`` level and the series execution continues. Creating a custom role includes the following steps: From ad4dcfab8714f4e6510130a9ba2b9c6fc811659a Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Tue, 8 Jul 2025 16:01:10 +0300 Subject: [PATCH 16/16] Updates by comments --- doc/platform/app/app_roles.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/platform/app/app_roles.rst b/doc/platform/app/app_roles.rst index f6757cb94..03956cb73 100644 --- a/doc/platform/app/app_roles.rst +++ b/doc/platform/app/app_roles.rst @@ -68,7 +68,7 @@ A custom application role is an object which implements custom functions or logi For example, a logging role can be created to add logging functionality on top of the built-in one. Since version :doc:`3.4.0 `, you can define an ``on_event`` callback for custom roles. The ``on_event`` callback is called -every time a ``box.status`` system event is broadcasted, or after the ``apply`` action of the configuration update is finished. +every time a ``box.status`` system event is broadcasted. If multiple custom roles have the ``on_event`` callback defined, these callbacks are called one after another in the order defined by roles dependencies. @@ -111,11 +111,10 @@ As a result, a role module should return an object that has corresponding functi stop = function() -- ... -- end, dependencies = { -- ... -- }, on_event = function(config, key, value) - local log = require('log') - - log.info('roles_cfg.my_role.foo: ' .. config.foo) - log.info('on_event is triggered by ' .. key) - log.info('is_ro: ' .. value.is_ro) + local log = require('log') + log.info('roles_cfg.my_role.foo: ' .. config.foo) + log.info('on_event is triggered by ' .. key) + log.info('is_ro: ' .. value.is_ro) end, }