Skip to content

Adds description of the on_event callback to custom application roles #5232

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

Merged
merged 16 commits into from
Jul 9, 2025

Conversation

AArdeev
Copy link
Contributor

@AArdeev AArdeev commented Jul 4, 2025

@AArdeev AArdeev requested a review from grafin July 4, 2025 14:03
@AArdeev AArdeev self-assigned this Jul 4, 2025
@@ -81,6 +110,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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to indent the function contents:

        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,

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 </release/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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO "the apply action of " this is not needed here. apply step is a part of the current inner implementation, and should not be important for the users.

Copy link
Member

@grafin grafin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work! Just some minor comments from me.

@xuniq xuniq self-requested a review July 8, 2025 13:12
@AArdeev AArdeev force-pushed the AArdeev/gh-4666-on-event-callback-for-roles branch from d4cba2f to ad4dcfa Compare July 9, 2025 07:01
@AArdeev AArdeev merged commit 39fe077 into latest Jul 9, 2025
1 check passed
@AArdeev AArdeev deleted the AArdeev/gh-4666-on-event-callback-for-roles branch July 9, 2025 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

on_event callback for roles
3 participants