struct

Arcana::Envelope

Inherits Struct < Value < Object

A message passed between agents via the Bus.

id and re are mail headers in the dot-ai sense, carried with the message and never set by the bus. id is the message's own id, the same on the sender's and the recipient's copy: hex, 8 digits or more (dot-ai computes it from the sender, the sent copy's name and the message). It isn't the correlation id, which a request and its reply share. re says what a message answers: a message's id, or a topic's post as #topic:<seq>. Either is dropped (nil) when it isn't in that form, so neither can carry anything else into a mail file's headers.

Constants

MESSAGE_ID = /\A[0-9a-fA-F]{8,64}\z/
REPLY_TO = /\A(?:[0-9a-fA-F]{8,64}|#[^\s:]+:\d+)\z/

Constructors

from_json(raw : String) : self
Source
new(from : String, to : String = "", subject : String = "", payload : JSON::Any = JSON::Any.new(nil), correlation_id : String = Random::Secure.hex(8), reply_to : String | Nil = nil, ordering : Ordering = Ordering::Auto, timestamp : Time = Time.utc, id : String | Nil = nil, re : String | Nil = nil)
Source

Instance methods

correlation_id
Source
correlation_id=(correlation_id : String)
Source
from
Source
from=(from : String)
Source
ordering
Source
ordering=(ordering : Ordering)
Source
payload
Source
payload=(payload : JSON::Any)
Source
reply(from : String, payload : JSON::Any, subject : String | Nil = nil) : Envelope

Create a reply to this envelope.

Source
reply_to
Source
reply_to=(reply_to : String | Nil)
Source
subject
Source
subject=(subject : String)
Source
timestamp
Source
timestamp=(timestamp : Time)
Source
to=(to : String)
Source
to_json(json : JSON::Builder) : Nil
Source