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.

signature is the sender's, carried to the receiver unchanged (see #signed, #signer and Signing). verified is the bus's stamp: true when the sender proved to the bus that from is its own. A bus sets it, and clears whatever a client wrote there.

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
from_json(parsed : JSON::Any) : 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, signature : Signature | Nil = nil, verified : Bool = false)
Source

Class methods

signature_of(raw : JSON::Any | Nil) : Signature | Nil

A signature as written in JSON, or nil when it isn't one.

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
signature
Source
signature=(signature : Signature | Nil)
Source
signed(key : Key) : Envelope

This envelope, signed by key. Sign it last: changing a field it covers afterwards voids the signature.

Source
signer

The public key that signed this envelope as it now stands, or nil when it isn't signed or the signature doesn't match. Whether that key is from's is the receiver's to check: against the key the directory lists for from, or one it already knows.

Source
subject
Source
subject=(subject : String)
Source
timestamp
Source
timestamp=(timestamp : Time)
Source
to=(to : String)
Source
to_json(json : JSON::Builder) : Nil
Source
verified
Source
verified=(verified : Bool)
Source

Nested types