Message#
- class Message(metadata: Metadata, content: RecordSet | None = None, error: Error | None = None)[源代码]#
基类:
object
State of your application from the viewpoint of the entity using it.
- 参数:
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.
Return True if message has content, else False.
Return True if message has an error, else False.
Attributes
The content of this message.
Error captured by this message.
A dataclass including information about the message to be executed.
- create_error_reply(error: Error, ttl: float | None = None) Message [源代码]#
Construct a reply message indicating an error happened.
- 参数:
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 [源代码]#
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.
- 参数:
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)
- 返回:
A new Message instance representing the reply.
- 返回类型: