MySQL 9.1.0
Source Code Documentation
event_tracking_global_variable_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_GLOBAL_VARIABLE_CONSUMER_HELPER_H
25#define EVENT_TRACKING_GLOBAL_VARIABLE_CONSUMER_HELPER_H
26
30
31/**
32 @file event_tracking_global_variable_consumer_helper.h
33 Helper file to create global_variable event consumer
34*/
35
36// clang-format off
37/**
38 @anchor EVENT_TRACKING_GLOBAL_VARIABLE_CONSUMER_EXAMPLE
39
40 @code
41
42 #include "mysql/components/util/event_tracking_global_variable_consumer_helper.h"
43
44 namespace Event_tracking_implementation {
45
46 // Replace following with union of subevents to be filtered
47 mysql_event_tracking_global_variable_subclass_t
48 Event_tracking_global_variable_implementation::filtered_sub_events = 0;
49
50 bool Event_tracking_global_variable_implementation::callback(
51 const mysql_event_tracking_global_variable_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_GLOBAL_VARIABLE(<implementation_name>);
61
62 BEGIN_COMPONENT_PROVIDES(<component_name>)
63 PROVIDES_SERVICE_EVENT_TRACKING_GLOBAL_VARIABLE(<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 IMPLEMENTS_SERVICE_EVENT_TRACKING_GLOBAL_VARIABLE(component) \
73 BEGIN_SERVICE_IMPLEMENTATION(component, event_tracking_global_variable) \
74 Event_tracking_implementation:: \
75 Event_tracking_global_variable_implementation::notify \
76 END_SERVICE_IMPLEMENTATION()
77
78#define PROVIDES_SERVICE_EVENT_TRACKING_GLOBAL_VARIABLE(component) \
79 PROVIDES_SERVICE(component, event_tracking_global_variable)
80
82/** Implementation helper class for global_variable events. */
84 public:
85 /** Sub-events to be filtered/ignored - To be defined by the component */
87
88 /** Callback function - To be implemented by component to handle an event */
90
91 /**
92 event_tracking_global_variable service implementation
93
94 @param [in] data Data related to global variable event
95
96 @returns Status of operation
97 @retval false Success
98 @retval true Failure
99 */
100 static DEFINE_BOOL_METHOD(
102 try {
103 if (!data) return true;
104 if (filtered_sub_events & data->event_subclass) return false;
105 return callback(data);
106 } catch (...) {
107 return true;
108 }
109 }
110};
111} // namespace Event_tracking_implementation
112
113#endif // !EVENT_TRACKING_GLOBAL_VARIABLE_CONSUMER_HELPER_H
Implementation helper class for global_variable events.
Definition: event_tracking_global_variable_consumer_helper.h:83
static bool callback(const mysql_event_tracking_global_variable_data *data)
Callback function - To be implemented by component to handle an event.
static mysql_event_tracking_global_variable_subclass_t filtered_sub_events
Sub-events to be filtered/ignored - To be defined by the component.
Definition: event_tracking_global_variable_consumer_helper.h:86
static mysql_service_status_t notify(const mysql_event_tracking_global_variable_data *data) noexcept
event_tracking_global_variable service implementation
Definition: event_tracking_global_variable_consumer_helper.h:101
Specifies macros to define Components.
unsigned long mysql_event_tracking_global_variable_subclass_t
Events for Global variable event tracking.
Definition: event_tracking_global_variable_defs.h:47
Globalvariable access 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 Global variable event tracking.
Definition: event_tracking_global_variable_defs.h:50
mysql_event_tracking_global_variable_subclass_t event_subclass
Event subclass.
Definition: event_tracking_global_variable_defs.h:52