Builds the event a <send> delivers, from the send effect the core
produced (ADR-0069 decision 4). Pure: no process, no clock, no lookup.
build/3 is the one construction site. Statifier.Session calls it for
every event a built-in <send> delivers to an external queue, and hands
its result to a registered processor (Statifier.Send.Processor) for a
send of a registered type. A host that drives Statifier.Interpreter
with no session reads the effect off the core and calls it itself.
What it stamps, per spec 5.10.1 and C.1:
nameis the send'sevent, anddataits resolved payload;sendidis the send id only when the author wroteidoridlocationon the<send>(the effect'sid_from_author?), andnilotherwise - C.1's empty-sendidrule;caller_contextis a delayed send's opaque host term (ADR-0063), andnilfor an immediate send, which carries none;origindefaults to the sender's#_scxml_<sessionid>location andorigintypeto the SCXML Event I/O Processor URI.
A processor with its own reply address passes :origin and
:origintype, so a receiver that answers "via the Event I/O Processor
specified in 'origintype'" (5.10.1) reaches that processor rather than
the sender's session.
Why the default origintype is the URI
C.1's prose says the field MUST have the value "scxml". The W3C
conformance suite requires the URI instead: test198 sends with no type
attribute and asserts _event.origintype == 'http://www.w3.org/TR/scxml/#SCXMLEventProcessor', test352 asserts the
same for an explicitly typed send, and test253 accepts either spelling.
No test in the corpus requires "scxml". The default follows the suite.
It is the URI whatever type the author wrote, so <send type="scxml">
also reports the URI where 5.10.1's "equivalent to the 'type' field on
the <send> element" would echo "scxml"; test253 accepts both and
nothing else covers it.
Summary
Functions
The %Statifier.Event{} that send delivers, sent by the session
session_id (spec 5.10's _sessionid). See the moduledoc for each
field.
Types
Functions
@spec build( send :: Statifier.Effect.Send.t() | Statifier.Effect.SendDelayed.t(), session_id :: String.t(), opts :: [option()] ) :: Statifier.Event.t()
The %Statifier.Event{} that send delivers, sent by the session
session_id (spec 5.10's _sessionid). See the moduledoc for each
field.
Examples
iex> send = %Statifier.Effect.Send{
...> event: "impression.joined",
...> data: %{"impression_id" => "imp-1"},
...> send_id: "send_1",
...> macrostep: 0,
...> microstep: 0,
...> round: 0
...> }
iex> event = Statifier.Send.Event.build(send, "sess_1")
iex> {event.name, event.data, event.sendid, event.origin}
{"impression.joined", %{"impression_id" => "imp-1"}, nil, "#_scxml_sess_1"}
iex> event = Statifier.Send.Event.build(send, "sess_1", origin: "myapp:reply/7", origintype: "myapp:execution")
iex> {event.origin, event.origintype}
{"myapp:reply/7", "myapp:execution"}