MySQL 8.4.0
Source Code Documentation
event_tracking_general_consumer_helper.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef EVENT_TRACKING_GENERAL_CONSUMER_HELPER_H
25#define EVENT_TRACKING_GENERAL_CONSUMER_HELPER_H
26
30
31/**
32 @file event_tracking_general_consumer_helper.h
33 Helper file to create general event consumer
34*/
35
36// clang-format off
37/**
38 @anchor EVENT_TRACKING_GENERAL_CONSUMER_EXAMPLE
39
40 @code
41
42 #include "mysql/components/util/event_tracking_general_consumer_helper.h"
43
44 namespace Event_tracking_implementation {
45
46 // Replace following with union of subevents to be filtered
47 mysql_event_tracking_general_subclass_t
48 Event_tracking_general_implementation::filtered_sub_events = 0;
49
50 bool Event_tracking_general_implementation::callback(
51 const mysql_event_tracking_general_data *data [[maybe_unused]]) {
52 // Your code goes here
53 }
54 } // namespace Event_tracking_implementation
55
56 // Define init/deinit methods for component
57
58 // Component declaration related stuff
59
60 IMPLEMENTS_SERVICE_EVENT_TRACKING_GENERAL(<implementation_name>);
61
62 BEGIN_COMPONENT_PROVIDES(<component_name>)
63 PROVIDES_SERVICE_EVENT_TRACKING_GENERAL(<implementation_name>)
64 END_COMPONENT_PROVIDES()
65
66 // Rest of the component declaration code
67
68 @endcode
69*/
70// clang-format on
71
72#define PROVIDES_SERVICE_EVENT_TRACKING_GENERAL(component) \
73 PROVIDES_SERVICE(component, event_tracking_general)
74
75#define IMPLEMENTS_SERVICE_EVENT_TRACKING_GENERAL(component) \
76 BEGIN_SERVICE_IMPLEMENTATION(component, event_tracking_general) \
77 Event_tracking_implementation::Event_tracking_general_implementation::notify \
78 END_SERVICE_IMPLEMENTATION()
79
81/** Implementation helper class for general events. */
83 public:
84 /** Sub-events to be filtered/ignored - To be defined by the component */
86
87 /** Callback function - To be implemented by component to handle an event */
89
90 /**
91 event_tracking_general service implementation
92
93 @param [in] data Data related to general event
94
95 @returns Status of operation
96 @retval false Success
97 @retval true Failure
98 */
101 try {
102 if (!data) return true;
103 if (filtered_sub_events & data->event_subclass) return false;
104 return callback(data);
105 } catch (...) {
106 return true;
107 }
108 }
109};
110} // namespace Event_tracking_implementation
111
112#endif // !EVENT_TRACKING_GENERAL_CONSUMER_HELPER_H
Implementation helper class for general events.
Definition: event_tracking_general_consumer_helper.h:82
static bool callback(const mysql_event_tracking_general_data *data)
Callback function - To be implemented by component to handle an event.
static mysql_event_tracking_general_subclass_t filtered_sub_events
Sub-events to be filtered/ignored - To be defined by the component.
Definition: event_tracking_general_consumer_helper.h:85
static mysql_service_status_t notify(const mysql_event_tracking_general_data *data) noexcept
event_tracking_general service implementation
Definition: event_tracking_general_consumer_helper.h:100
Specifies macros to define Components.
unsigned long mysql_event_tracking_general_subclass_t
Events for the General event tracking.
Definition: event_tracking_general_defs.h:52
General event tracking.
Definition: event_tracking_authentication_consumer_helper.h:81
Specifies macros to define Service Implementations.
#define DEFINE_BOOL_METHOD(name, args)
A short macro to define method that returns bool, which is the most common case.
Definition: service_implementation.h:88
Structure for General event tracking.
Definition: event_tracking_general_defs.h:59
mysql_event_tracking_general_subclass_t event_subclass
Event subclass.
Definition: event_tracking_general_defs.h:61