MySQL 8.0.39
Source Code Documentation
Event_handler Class Referenceabstract

Interface for the application of events, them being packets or log events. More...

#include <pipeline_interfaces.h>

Inheritance diagram for Event_handler:
[legend]

Public Member Functions

 Event_handler ()
 
virtual ~Event_handler ()=default
 
virtual int initialize ()=0
 Initialization as defined in the handler implementation. More...
 
virtual int terminate ()=0
 Terminate the execution as defined in the handler implementation. More...
 
virtual int handle_event (Pipeline_event *event, Continuation *continuation)=0
 Handling of an event as defined in the handler implementation. More...
 
virtual int handle_action (Pipeline_action *action)=0
 Handling of an action as defined in the handler implementation. More...
 
void plug_next_handler (Event_handler *next_handler)
 Plug an handler to be the next in line for execution. More...
 
void append (Event_handler *last_handler)
 Append an handler to be the last in line for execution. More...
 
virtual bool is_unique ()=0
 This method identifies the handler as being unique. More...
 
virtual int get_role ()=0
 This method returns the handler role. More...
 
int terminate_pipeline ()
 Shutdown and delete all handlers in the pipeline. More...
 

Static Public Member Functions

static void append_handler (Event_handler **pipeline, Event_handler *event_handler)
 Append an handler to a given pipeline. More...
 
static void get_handler_by_role (Event_handler *pipeline, int role, Event_handler **event_handler)
 Returns an handler that plays the given role. More...
 

Protected Member Functions

int next (Pipeline_event *event, Continuation *continuation)
 Pass the event to the next handler in line. More...
 
int next (Pipeline_action *action)
 Pass the action to the next handler in line. More...
 

Private Attributes

Event_handlernext_in_pipeline
 

Detailed Description

Interface for the application of events, them being packets or log events.

Instances of this class can be composed among them to form execution pipelines.

Handlers can also have roles that define their type of activity and can be used to identify them in a pipeline. Roles are defined by the user of this class according to his context.

Constructor & Destructor Documentation

◆ Event_handler()

Event_handler::Event_handler ( )
inline

◆ ~Event_handler()

virtual Event_handler::~Event_handler ( )
virtualdefault

Member Function Documentation

◆ append()

void Event_handler::append ( Event_handler last_handler)
inline

Append an handler to be the last in line for execution.

Parameters
[in]last_handlerthe last handler in line

◆ append_handler()

static void Event_handler::append_handler ( Event_handler **  pipeline,
Event_handler event_handler 
)
inlinestatic

Append an handler to a given pipeline.

Note
if the pipeline is null, the given handler will take its place
Parameters
[in,out]pipelinethe pipeline to append the handler
[in]event_handlerthe event handler to append

◆ get_handler_by_role()

static void Event_handler::get_handler_by_role ( Event_handler pipeline,
int  role,
Event_handler **  event_handler 
)
inlinestatic

Returns an handler that plays the given role.

Note
if the pipeline is null, or the handler is not found, the retrieved handler will be null.
Parameters
[in]pipelinethe handler pipeline
[in]rolethe role to retrieve
[out]event_handlerthe retrieved event handler

◆ get_role()

virtual int Event_handler::get_role ( )
pure virtual

This method returns the handler role.

Handlers can have different roles according to the tasks they represent. Is based on this role that certain components can extract and interact with pipeline handlers. This means that if a role is given to a singleton handler, no one else can have that role.

Returns
the handler role

Implemented in Applier_handler, Certification_handler, and Event_cataloger.

◆ handle_action()

virtual int Event_handler::handle_action ( Pipeline_action action)
pure virtual

Handling of an action as defined in the handler implementation.

As the handler can be included in a pipeline, somewhere in the method, the handler.next(action) method shall be invoked to allow the passing of the action to the next handler.

Note
Actions should not be treated asynchronously and as so, Continuations are not used here. Errors are returned directly or passed by in the action if it includes support for such
Parameters
[in]actionthe pipeline event to be handled

Implemented in Applier_handler, Certification_handler, and Event_cataloger.

◆ handle_event()

virtual int Event_handler::handle_event ( Pipeline_event event,
Continuation continuation 
)
pure virtual

Handling of an event as defined in the handler implementation.

As the handler can be included in a pipeline, somewhere in the method, the handler.next(event,continuation) method shall be invoked to allow the passing of the event to the next handler.

Also, if an error occurs, the continuation object shall be used to propagate such error. This class can also be used to know/report when the transaction to whom the event belongs was discarded.

Parameters
[in]eventthe pipeline event to be handled
[in,out]continuationtermination notification object.

Implemented in Applier_handler, Certification_handler, and Event_cataloger.

◆ initialize()

virtual int Event_handler::initialize ( )
pure virtual

Initialization as defined in the handler implementation.

Note
It's up to the developer to decide its own initialization strategy, but the suggested approach is to initialize basic structures here and then depend on Action packets to configure and start existing handler routines.

Implemented in Applier_handler, Certification_handler, and Event_cataloger.

◆ is_unique()

virtual bool Event_handler::is_unique ( )
pure virtual

This method identifies the handler as being unique.

An handler that is defined as unique is an handler that cannot be used more than once in a pipeline. Such tasks as certification and event application can only be done once. Unique handlers are also the only that, by being one of a kind, can be extracted during the pipeline life allowing dynamic changes to them.

Returns
if the handler is the a unique handler
Return values
trueis a unique handler
falseis a repeatable handler

Implemented in Applier_handler, Certification_handler, and Event_cataloger.

◆ next() [1/2]

int Event_handler::next ( Pipeline_action action)
inlineprotected

Pass the action to the next handler in line.

If none exists, this method will return

Parameters
[in]actionthe pipeline action to be handled

◆ next() [2/2]

int Event_handler::next ( Pipeline_event event,
Continuation continuation 
)
inlineprotected

Pass the event to the next handler in line.

If none exists, this method will signal the continuation method and exit.

Parameters
[in]eventthe pipeline event to be handled
[in,out]continuationtermination notification object.

◆ plug_next_handler()

void Event_handler::plug_next_handler ( Event_handler next_handler)
inline

Plug an handler to be the next in line for execution.

Parameters
[in]next_handlerthe next handler in line

◆ terminate()

virtual int Event_handler::terminate ( )
pure virtual

Terminate the execution as defined in the handler implementation.

Implemented in Applier_handler, Certification_handler, and Event_cataloger.

◆ terminate_pipeline()

int Event_handler::terminate_pipeline ( )
inline

Shutdown and delete all handlers in the pipeline.

Returns
the operation status
Return values
0OK
!=0Error

Member Data Documentation

◆ next_in_pipeline

Event_handler* Event_handler::next_in_pipeline
private

The documentation for this class was generated from the following file: