Message#

class Message(metadata: Metadata, content: RecordSet | None = None, error: Error | None = None)[source]#

Bases : object

State of your application from the viewpoint of the entity using it.

Paramètres:
  • metadata (Metadata) – A dataclass including information about the message to be executed.

  • content (Optional[RecordSet]) – Holds records either sent by another entity (e.g. sent by the server-side logic to a client, or vice-versa) or that will be sent to it.

  • error (Optional[Error]) – A dataclass that captures information about an error that took place when processing another message.

Methods

create_error_reply(error[, ttl])

Construct a reply message indicating an error happened.

create_reply(content[, ttl])

Create a reply to this message with specified content and TTL.

has_content()

Return True if message has content, else False.

has_error()

Return True if message has an error, else False.

Attributes

content

The content of this message.

error

Error captured by this message.

metadata

A dataclass including information about the message to be executed.

property content: RecordSet#

The content of this message.

create_error_reply(error: Error, ttl: float | None = None) Message[source]#

Construct a reply message indicating an error happened.

Paramètres:
  • error (Error) – The error that was encountered.

  • ttl (Optional[float] (default: None)) –

    Time-to-live for this message in seconds. If unset, it will be set based on the remaining time for the received message before it expires. This follows the equation:

    ttl = msg.meta.ttl - (reply.meta.created_at - msg.meta.created_at)

create_reply(content: RecordSet, ttl: float | None = None) Message[source]#

Create a reply to this message with specified content and TTL.

The method generates a new Message as a reply to this message. It inherits “run_id”, “src_node_id”, “dst_node_id”, and “message_type” from this message and sets “reply_to_message” to the ID of this message.

Paramètres:
  • content (RecordSet) – The content for the reply message.

  • ttl (Optional[float] (default: None)) –

    Time-to-live for this message in seconds. If unset, it will be set based on the remaining time for the received message before it expires. This follows the equation:

    ttl = msg.meta.ttl - (reply.meta.created_at - msg.meta.created_at)

Renvoie:

A new Message instance representing the reply.

Type renvoyé:

Message

property error: Error#

Error captured by this message.

has_content() bool[source]#

Return True if message has content, else False.

has_error() bool[source]#

Return True if message has an error, else False.

property metadata: Metadata#

A dataclass including information about the message to be executed.