messaging.messages package

Submodules

messaging.messages.chain module

class messaging.messages.chain.ChainCommandMessage

Bases: messaging.messages.message.CommandMessage

execute()

See messaging.messages.message.CommandMessage.execute()

static from_json(json_dict)

See messaging.messages.message.CommandMessage.from_json()

to_json()

See messaging.messages.message.CommandMessage.to_json()

messaging.messages.echo module

class messaging.messages.echo.EchoCommandMessage

Bases: messaging.messages.message.CommandMessage

execute()

See messaging.messages.message.CommandMessage.execute()

static from_json(json_dict)

See messaging.messages.message.CommandMessage.from_json()

to_json()

See messaging.messages.message.CommandMessage.to_json()

messaging.messages.factory module

Defines the factory for creating messages

messaging.messages.factory.add_message_type(message_class)

Registers a message class so it can be used for Scale messaging

Parameters:message_class (class:messaging.messages.CommandMessage) – The class definition for a message
messaging.messages.factory.get_message_type(message_type)

Returns a message class of the given type

Parameters:
  • message_type (string) – The unique identifier of a registered message type
  • message_class (class:messaging.messages.CommandMessage) – The class definition for a message
messaging.messages.factory.get_message_types()

Returns a list of type identifiers for all registered message types

Returns:A list of messages types
Return type:[string]

messaging.messages.fail module

class messaging.messages.fail.FailCommandMessage

Bases: messaging.messages.message.CommandMessage

execute()

See messaging.messages.message.CommandMessage.execute()

static from_json(json_dict)

See messaging.messages.message.CommandMessage.from_json()

to_json()

See messaging.messages.message.CommandMessage.to_json()

messaging.messages.message module

class messaging.messages.message.CommandMessage(message_type)

Bases: object

This ABC defines the interface all CommandMessage classes should implement.

If a CommandMessage needs to chain processing together, it should define this via the new_messages array.

execute()

Processing logic for all command messages should be implemented within this method.

It is critical that execution of messages is idempotent - no side effects as result of repeated executions. Without idempotency we cannot support messaging backends such as SQS which guarantee ‘at least once’ delivery. No assurances are provided for message ordering, due to the asynchronous nature of messaging system with many potential message producers and consumers.

Returns:Success or failure of execute operation
Return type:bool
static from_json(json_dict)

JSON deserializer for CommandMessage subclasses. Must be implemented in all subclasses.

Parameters:json_dict (dict) – CommandMessage JSON representation to reconstitute into class instance.
Returns:Instantiated class from input JSON
Return type:messaging.messages.CommandMessage
to_json()

JSON Serializer for CommandMessage subclasses. Must be implemented in all subclasses.

Returns:JSON representation of CommandMessage class.
Return type:dict

Module contents