pipert.core.message_handlers

Module Contents

Classes

MessageHandler

Helper class that provides a standard way to create an ABC using

RedisHandler

Helper class that provides a standard way to create an ABC using

class pipert.core.message_handlers.MessageHandler[source]

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract receive(self, in_key)[source]

Receives the latest message from the message broker.

Args:

in_key: the name of the queue/stream at which the relevant message is located.

abstract read_next_msg(self, in_key)[source]

Reads the following message from the one that was last read, if no message has been read before, then read the last message in the message broker cannot read the same message twice.

Args:

in_key: the name of the queue/stream at which the relevant message is located.

abstract read_most_recent_msg(self, in_key)[source]

Reads the latest message in the message broker, cannot read the same message twice.

Args:

in_key: the name of the queue/stream at which the relevant message is located.

abstract send(self, out_key, msg)[source]

Sends a message to the message broker.

Args:

out_key: the name of the queue/stream at which the relevant message will be placed. msg: the message object that is being sent.

abstract connect(self)[source]

Establishes a connection to the message broker.

abstract close(self)[source]

Closes the connection to the message broker.

class pipert.core.message_handlers.RedisHandler(url, maxlen=100)[source]

Bases: pipert.core.message_handlers.MessageHandler

Helper class that provides a standard way to create an ABC using inheritance.

read_next_msg(self, in_key)[source]

Reads the following message from the one that was last read, if no message has been read before, then read the last message in the message broker cannot read the same message twice.

Args:

in_key: the name of the queue/stream at which the relevant message is located.

read_most_recent_msg(self, in_key)[source]

Reads the latest message in the message broker, cannot read the same message twice.

Args:

in_key: the name of the queue/stream at which the relevant message is located.

receive(self, in_key)[source]

Receives the latest message from the message broker.

Args:

in_key: the name of the queue/stream at which the relevant message is located.

_read_from_redis_using_method(self, in_key, reading_method, **method_args)[source]
send(self, out_key, msg)[source]

Sends a message to the message broker.

Args:

out_key: the name of the queue/stream at which the relevant message will be placed. msg: the message object that is being sent.

connect(self)[source]

Establishes a connection to the message broker.

close(self)[source]

Closes the connection to the message broker.

static _add_offset_to_stream_id(stream_id, offset)[source]