From: Aurelien DARRAGON Date: Wed, 6 Nov 2024 16:10:52 +0000 (+0100) Subject: MINOR: event_hdl: add PAT_REF events X-Git-Tag: v3.2-dev1~82 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f7267bd31541f3fc66cef5c0e9c36ef293b501be;p=thirdparty%2Fhaproxy.git MINOR: event_hdl: add PAT_REF events This is some prerequisite work for implementing PAT_REF events. In this commit we define the PAT_REF event_hdl family (which gets family slot id #2), with the following supported events: - EVENT_HDL_SUB_PAT_REF_ADD: element was added to the current version of the pattern ref - EVENT_HDL_SUB_PAT_REF_DEL: element was deleted from the current version of the pattern ref - EVENT_HDL_SUB_PAT_REF_SET: element was modified in the current version of the pattern ref - EVENT_HDL_SUB_PAT_REF_COMMIT: pending element(s) was/were commited in the current version of the pattern ref - EVENT_HDL_SUB_PAT_REF_CLEAR: all elements were cleared from the current version of the pattern ref The goal is to be able to track a pat_ref struct in order to be notified when it is updated. For performance reasons, events from this family won't provide any additional info, and will only be published in the pat_ref subscription list. Indeed, pat_ref may be updated at a relatively high frequency (or worse, batch work), so we cannot afford doing expensive treatment for each update. --- diff --git a/include/haproxy/event_hdl-t.h b/include/haproxy/event_hdl-t.h index d4998521d7..85d13bea72 100644 --- a/include/haproxy/event_hdl-t.h +++ b/include/haproxy/event_hdl-t.h @@ -263,8 +263,6 @@ struct event_hdl_sub { * event type to string conversions */ -/* TODO */ - /* SERVER FAMILY, provides event_hdl_cb_data_server struct * (will be defined in haproxy/server-t.h) */ @@ -282,6 +280,16 @@ struct event_hdl_sub { /* server inet addr (addr:svc_port tuple) change event */ #define EVENT_HDL_SUB_SERVER_INETADDR EVENT_HDL_SUB_TYPE(1,8) +/* PAT_REF family, only published in pat ref subscription list + * (not published in global subscription list for performance reasons) + */ +#define EVENT_HDL_SUB_PAT_REF EVENT_HDL_SUB_FAMILY(2) +#define EVENT_HDL_SUB_PAT_REF_ADD EVENT_HDL_SUB_TYPE(2,1) +#define EVENT_HDL_SUB_PAT_REF_DEL EVENT_HDL_SUB_TYPE(2,2) +#define EVENT_HDL_SUB_PAT_REF_SET EVENT_HDL_SUB_TYPE(2,3) +#define EVENT_HDL_SUB_PAT_REF_COMMIT EVENT_HDL_SUB_TYPE(2,4) +#define EVENT_HDL_SUB_PAT_REF_CLEAR EVENT_HDL_SUB_TYPE(2,5) + /* --------------------------------------- */ /* Please reflect changes above in event_hdl_sub_type_map defined diff --git a/src/event_hdl.c b/src/event_hdl.c index caef654840..ad480f59f8 100644 --- a/src/event_hdl.c +++ b/src/event_hdl.c @@ -42,6 +42,12 @@ static struct event_hdl_sub_type_map event_hdl_sub_type_map[] = { {"SERVER_ADMIN", EVENT_HDL_SUB_SERVER_ADMIN}, {"SERVER_CHECK", EVENT_HDL_SUB_SERVER_CHECK}, {"SERVER_INETADDR", EVENT_HDL_SUB_SERVER_INETADDR}, + {"PAT_REF", EVENT_HDL_SUB_PAT_REF}, + {"PAT_REF_ADD", EVENT_HDL_SUB_PAT_REF_ADD}, + {"PAT_REF_DEL", EVENT_HDL_SUB_PAT_REF_DEL}, + {"PAT_REF_SET", EVENT_HDL_SUB_PAT_REF_SET}, + {"PAT_REF_COMMIT", EVENT_HDL_SUB_PAT_REF_COMMIT}, + {"PAT_REF_CLEAR", EVENT_HDL_SUB_PAT_REF_CLEAR}, }; /* internal types (only used in this file) */