MySQL 8.3.0
Source Code Documentation
Gcs_message Class Reference

Class that represents the data that is exchanged within a group. More...

#include <gcs_message.h>

Public Member Functions

 Gcs_message (const Gcs_member_identifier &origin, const Gcs_group_identifier &destination, Gcs_message_data *message_data)
 Gcs_message 1st constructor. More...
 
 Gcs_message (const Gcs_member_identifier &origin, Gcs_message_data *message_data)
 Gcs_message 2nd constructor. More...
 
virtual ~Gcs_message ()
 
const Gcs_member_identifierget_origin () const
 
const Gcs_group_identifierget_destination () const
 
Gcs_message_dataget_message_data () const
 

Private Member Functions

void init (const Gcs_member_identifier *origin, const Gcs_group_identifier *destination, Gcs_message_data *message_data)
 
 Gcs_message (Gcs_message const &)
 
Gcs_messageoperator= (Gcs_message const &)
 

Private Attributes

Gcs_member_identifierm_origin
 
Gcs_group_identifierm_destination
 
Gcs_message_datam_data
 

Detailed Description

Class that represents the data that is exchanged within a group.

It is sent by a member having the group as destination. It shall be received by all members that pertain to the group in that moment.

It is built using two major blocks: the header and the payload of the message. A user of Gcs_message can freely add data to the header and to the payload.

Each binding implementation might use these two fields at its own discretion but that data should be removed from the header/payload before its delivery to the client layer.

When the message is built, none of the data is passed unto it. One has to use the append_* methods in order to append data. Calling encode() at the end will provide a ready-to-send message.

On the receiver side, one shall use decode() in order to have the header and the payload restored in the original message fields.

A typical use case of sending a message is:

Gcs_control_interface *gcs_ctrl_interface_instance;
Gcs_communication_interface *gcs_comm_interface_instance; // obtained
// previously
gcs_ctrl_interface_instance->get_local_information();
Gcs_group_identifier destination("the_group");
Gcs_message *msg= new Gcs_message(&myself, new Gcs_message_data(0, 3));
uchar[] some_data= {(uchar)0x12,
(uchar)0x24,
(uchar)0x00};
strlen(some_data));
gcs_comm_interface_instance->send_message(msg);
This interface represents all the communication facilities that a binding implementation should provi...
Definition: gcs_communication_interface.h:89
virtual enum_gcs_error send_message(const Gcs_message &message_to_send)=0
Method used to broadcast a message to a group in which this interface pertains.
This interface represents all the control functionalities that a binding implementation must provide.
Definition: gcs_control_interface.h:110
This represents the unique identification of a group.
Definition: gcs_group_identifier.h:34
It represents the identity of a group member within a certain group.
Definition: gcs_member_identifier.h:39
This class serves as data container for information flowing in the GCS ecosystem.
Definition: gcs_message.h:47
bool append_to_payload(const uchar *to_append, uint64_t to_append_len)
Appends data to the payload of the message.
Definition: gcs_message.cc:159
Class that represents the data that is exchanged within a group.
Definition: gcs_message.h:356
Gcs_message_data & get_message_data() const
Definition: gcs_message.cc:351
Gcs_message(const Gcs_member_identifier &origin, const Gcs_group_identifier &destination, Gcs_message_data *message_data)
Gcs_message 1st constructor.
Definition: gcs_message.cc:322
unsigned char uchar
Definition: my_inttypes.h:51

A typical use case of receiving a message is:

class my_Gcs_communication_event_listener : Gcs_communication_event_listener
{
my_Gcs_communication_event_listener(my_Message_delegator *delegator)
{
this->delegator= delegator;
}
void on_message_received(Gcs_message &message)
{
// Do something when message arrives...
delegator->process_gcs_message(message);
}
private:
my_Message_delegator *delegator;
}
This interface is implemented by those who wish to receive messages.
Definition: gcs_communication_event_listener.h:35

Constructor & Destructor Documentation

◆ Gcs_message() [1/3]

Gcs_message::Gcs_message ( const Gcs_member_identifier origin,
const Gcs_group_identifier destination,
Gcs_message_data message_data 
)
explicit

Gcs_message 1st constructor.

Gcs_message implementation.

This is used to build full messages.

Note that the Gcs_message will acquire ownership of the data, i.e. Gcs_message_data, and will be responsible for deleting it.

Parameters
[in]originThe group member that sent the message
[in]destinationThe group in which this message belongs
[in]message_dataExternal message data object.

◆ Gcs_message() [2/3]

Gcs_message::Gcs_message ( const Gcs_member_identifier origin,
Gcs_message_data message_data 
)
explicit

Gcs_message 2nd constructor.

This is used to send messages but with an external Gcs_message_data object.

Note that the Gcs_message will acquire ownership of the data, i.e. Gcs_message_data, and will be responsible for deleting it.

Parameters
[in]originThe group member that sent the message
[in]message_dataExternal message data object.

◆ ~Gcs_message()

Gcs_message::~Gcs_message ( )
virtual

◆ Gcs_message() [3/3]

Gcs_message::Gcs_message ( Gcs_message const &  )
private

Member Function Documentation

◆ get_destination()

const Gcs_group_identifier * Gcs_message::get_destination ( ) const
Returns
the destination of this message. It might be NULL.

◆ get_message_data()

Gcs_message_data & Gcs_message::get_message_data ( ) const
Returns
the message data to be filled.

◆ get_origin()

const Gcs_member_identifier & Gcs_message::get_origin ( ) const
Returns
the origin of this message

◆ init()

void Gcs_message::init ( const Gcs_member_identifier origin,
const Gcs_group_identifier destination,
Gcs_message_data message_data 
)
private

◆ operator=()

Gcs_message & Gcs_message::operator= ( Gcs_message const &  )
private

Member Data Documentation

◆ m_data

Gcs_message_data* Gcs_message::m_data
private

◆ m_destination

Gcs_group_identifier* Gcs_message::m_destination
private

◆ m_origin

Gcs_member_identifier* Gcs_message::m_origin
private

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