11 Messages
(require denxi/message) | package: denxi |
A message is an instance of the $message prefab structure used to share information in the Denxi runtime, in logs, and between processes. When the term “message” is ambiguous, then Denxi message applies the context of this section.
Message types may form a heirarchy using colon-separated identifiers that start with $. The $message type itself has no semantics beyond serving as the root type, and its identifier does not appear in other structure type identifiers. For example, identifiers pertaining to command line messages start with $cli, not $message:cli.
The type heirarchy serves only to organize statements under a given topic. Meaning that a $transfer:budget? would capture messages pertaining to a budget for a byte transfer, but an instance of $transfer:budget:exceeded is an exact statement reporting an overrun.
A message may require another message to serve as context. A type heirarchy is unhelpful for this purpose, since $transfer:budget:exceeded could apply to a download in the context of a build process or a verification process. It is difficult to define a single type to capture this kind of variation, so Denxi instead composes messages into machine-readable documents.
syntax
(define-message id [field-expr ...])
(define-message id super-id [field-expr ...])
The second form allows declaration of a supertype, but that supertype must be a subtype of $message.
syntax
(define+provide-message id form ...)
struct
(struct $show-datum $message (value) #:prefab) value : any/c
struct
(struct $show-string $message (message) #:prefab) message : any/c
struct
(struct $regarding $message (subject body) #:prefab) subject : $message? body : $message?
procedure
(scope-message m [scope]) → $message?
m : $message? scope : (listof $message?) = (get-message-scope)
Otherwise, returns (scope-message ($regarding (car scope) m) (cdr scope)).
Use to wrap a message with $regarding, where the exact structure of the output may depend on the current dynamic extent.
procedure
(call-in-message-scope m proc) → any
m : $message proc : (-> any)
syntax
(in-message-scope m body ...)
procedure
(get-message-scope) → (listof $message?)