MINOR: hlua/event_hdl: expose SERVER_CHECK event

Exposing SERVER_CHECK event through the lua API.

New lua class named ServerEventCheck was added to provide additional
data for SERVER_CHECK event.

Lua documentation was updated accordingly.
This commit is contained in:
Aurelien DARRAGON 2023-03-30 15:53:33 +02:00 committed by Christopher Faulet
parent dcbc2d2cac
commit 0bd53b2152
2 changed files with 25 additions and 0 deletions

View File

@ -948,6 +948,9 @@ Core class
* **SERVER_UP**: when a server state goes from DOWN to UP
* **SERVER_STATE**: when a server state changes
* **SERVER_ADMIN**: when a server administrative state changes
* **SERVER_CHECK**: when a server's check status change is reported.
Be careful when subscribing to this type since many events might be
generated.
.. Note::
Use **SERVER** in **event_types** to subscribe to all server events types
@ -1541,6 +1544,13 @@ See :js:func:`core.event_sub()` for more info.
.. Note::
Only available for SERVER_ADMIN event
.. js:attribute:: ServerEvent.check
A :ref:`server_event_checkres_class`
.. Note::
Only available for SERVER_CHECK event
.. _server_event_checkres_class:
ServerEventCheckRes class

View File

@ -9259,6 +9259,21 @@ __LJMP static void hlua_event_hdl_cb_push_args(struct hlua_event_sub *hlua_sub,
lua_settable(hlua->T, -3); /* admin table */
}
else if (event_hdl_sub_type_equal(EVENT_HDL_SUB_SERVER_CHECK, event)) {
struct event_hdl_cb_data_server_check *check = data;
if (!lua_checkstack(hlua->T, 20))
WILL_LJMP(luaL_error(hlua->T, "Lua out of memory error."));
/* check subclass */
lua_pushstring(hlua->T, "check");
lua_newtable(hlua->T);
/* check result snapshot */
hlua_event_hdl_cb_push_event_checkres(hlua->T, &check->safe.res);
lua_settable(hlua->T, -3); /* check table */
}
/* attempt to provide reference server object
* (if it wasn't removed yet, SERVER_DEL will never succeed here)