1 /* Copyright (c) 2016, 2021, 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 also distributed 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 included with MySQL. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License, version 2.0, for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 23 #ifndef CONNECTION_CONTROL_COORDINATOR_H 24 #define CONNECTION_CONTROL_COORDINATOR_H 25 26 #include "connection_control_interfaces.h" /* Connection_event_coordinator_services */ 27 #include "connection_control_memory.h" /* Connection_control_alloc */ 28 29 namespace connection_control 30 { 31 /** 32 Connection event coordinator. 33 This class will keep list of subscribers for different subevents 34 and notify them based on their preference. 35 */ 36 37 class Connection_event_coordinator : public Connection_event_coordinator_services, 38 public Connection_control_alloc 39 { 40 public: Connection_event_coordinator()41 Connection_event_coordinator() 42 { 43 reset(); 44 } ~Connection_event_coordinator()45 ~Connection_event_coordinator() 46 { 47 reset(); 48 } 49 50 /* Functions to receive notification from server */ 51 void notify_event(MYSQL_THD thd, 52 Error_handler * error_handler, 53 const mysql_event_connection *connection_event); 54 void notify_sys_var(Error_handler * error_handler, 55 opt_connection_control variable, 56 void *new_value); 57 58 /* Services provided to observers */ 59 bool register_event_subscriber(Connection_event_observer **subscriber, 60 std::vector<opt_connection_control> *sys_vars, 61 std::vector<stats_connection_control> *status_vars); 62 63 bool notify_status_var(Connection_event_observer **observer, 64 stats_connection_control status_var, 65 status_var_action action); 66 67 private: 68 void reset(); 69 class Connection_event_subscriber 70 { 71 public: 72 Connection_event_observer * m_subscriber; 73 bool m_sys_vars[OPT_LAST]; 74 }; 75 76 std::vector<Connection_event_subscriber> m_subscribers; 77 Connection_event_observer *m_status_vars_subscription[STAT_LAST]; 78 }; 79 } 80 #endif // !CONNECTION_CONTROL_COORDINATOR_H 81