]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: event_hdl: add PAT_REF events
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 6 Nov 2024 16:10:52 +0000 (17:10 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Fri, 29 Nov 2024 06:22:18 +0000 (07:22 +0100)
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.

include/haproxy/event_hdl-t.h
src/event_hdl.c

index d4998521d7a4472e8af153c6bcbe02a509d68c46..85d13bea7205a424524934649d59448dfe137d18 100644 (file)
@@ -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
index caef654840b44ccf4e549e0e71a3ac0d9fc9e6ab..ad480f59f8b69836275ccba6cd002d06ac8ab21d 100644 (file)
@@ -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) */