MySQL 8.4.2
Source Code Documentation
event_tracking_parse_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_PARSE_CONSUMER_HELPER_H
25#define EVENT_TRACKING_PARSE_CONSUMER_HELPER_H
26
30
31/**
32 @file event_tracking_parse_consumer_helper.h
33 Helper file to create parse event consumer
34*/
35
36// clang-format off
37/**
38 @anchor EVENT_TRACKING_PARSE_CONSUMER_EXAMPLE
39
40 @code
41
42 #include "mysql/components/util/event_tracking_parse_consumer_helper.h"
43
44 namespace Event_tracking_implementation {
45
46 // Replace following with union of subevents to be filtered
47 mysql_event_tracking_parse_subclass_t
48 Event_tracking_parse_implementation::filtered_sub_events = 0;
49
50 bool Event_tracking_parse_implementation::callback(
51 const mysql_event_tracking_parse_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_PARSE(<implementation_name>);
61
62 BEGIN_COMPONENT_PROVIDES(<component_name>)
63 PROVIDES_SERVICE_EVENT_TRACKING_PARSE(<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_PARSE(component) \
73 PROVIDES_SERVICE(component, event_tracking_parse)
74
75#define IMPLEMENTS_SERVICE_EVENT_TRACKING_PARSE(component) \
76 BEGIN_SERVICE_IMPLEMENTATION(component, event_tracking_parse) \
77 Event_tracking_implementation::Event_tracking_parse_implementation::notify \
78 END_SERVICE_IMPLEMENTATION()
79
81/** Implementation helper class for parse 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_parse service implementation
92
93 @param [in] data Data related to parse event
94
95 @returns Status of operation
96 @retval false Success
97 @retval true Failure
98 */
100 try {
101 if (!data) return true;
102 if (filtered_sub_events & data->event_subclass) return false;
103 return callback(data);
104 } catch (...) {
105 return true;
106 }
107 }
108};
109} // namespace Event_tracking_implementation
110
111#endif // !EVENT_TRACKING_PARSE_CONSUMER_HELPER_H
Implementation helper class for parse events.
Definition: event_tracking_parse_consumer_helper.h:82
static mysql_service_status_t notify(mysql_event_tracking_parse_data *data) noexcept
event_tracking_parse service implementation
Definition: event_tracking_parse_consumer_helper.h:99
static bool callback(mysql_event_tracking_parse_data *data)
Callback function - To be implemented by component to handle an event.
static mysql_event_tracking_parse_subclass_t filtered_sub_events
Sub-events to be filtered/ignored - To be defined by the component.
Definition: event_tracking_parse_consumer_helper.h:85
Specifies macros to define Components.
unsigned long mysql_event_tracking_parse_subclass_t
Events for Parse event tracking.
Definition: event_tracking_parse_defs.h:47
Parse 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 the Parse event tracking.
Definition: event_tracking_parse_defs.h:68
mysql_event_tracking_parse_subclass_t event_subclass
MYSQL_AUDIT_[PRE|POST]_PARSE event id.
Definition: event_tracking_parse_defs.h:73