MySQL 9.1.0
Source Code Documentation
How to create a new producer component

A new producer component would typically mean new set of events being introduced.

In such a case, new services should be introduced - just like existing set of event tracking services. E.g. something like following:

BEGIN_SERVICE_DEFINITION(event_tracking_<new_service_name>)
(const mysql_<new_service_name>_data *data));
END_SERVICE_DEFINITION(event_tracking_<new_service_name>)
static bool notify(SvcTypes svc_type, Notification_context &ctx)
Auxiliary function to engage the service registry to notify a set of listeners.
Definition: notification.cc:87
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition: service.h:91
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:86
#define DECLARE_BOOL_METHOD(name, args)
Declares a method that returns bool as a part of the Service definition.
Definition: service.h:112

Once introduced, producer should be able to broadcast the event to all interested consumer. To achieve that, a consumer should do following:

  • Define a new reference caching change using s_mysql_reference_caching_channel
  • Create a reference caching cache to obtain references to all interested component
  • Iterate over the reference cache and notify each consumer component

Further, a consumer component may be uninstalled at any time. To facilitate that, the reference cache created by the producer should release corresponding reference. This can be achieved by implementing s_mysql_dynamic_loader_services_unload_notification and refreshing reference caches as a part of it. Reference caching component will take care of informing the producer whenever a component is being uinstalled.

In addition, developer may also think about writing wrappers to facilitate development of consumer component. For example see EVENT_TRACKING_GENERAL_CONSUMER_EXAMPLE.