The pure part of an agent's pipeline.
The core holds the processors, delivers frames between them, and executes
their effects. It starts no processes and sends no messages. Each call
returns a list of commands for its host to carry out, and the host feeds
task results, timer expiries and messages back in. Hosts are the room
worker (Octoroom.Agent.Worker) and the test harness
(Octoroom.Agent.Pipeline.Test).
Commands:
{:output, frame}- a frame left the last stage downstream{:output_upstream, frame}- a frame left the first stage upstream (anErrorframe there should end the call){:start_task, id, fun}- runfun.(emit); report each emitted message and then{:done, result}(or{:failed, reason}) withasync_message/3{:kill_task, id}- kill that task; anything it still reports is dropped{:start_timer, id, ms}/{:cancel_timer, id}- calltimer_fired/2afterms{:notify, event}- sendeventto the session owner{:interrupted, generation}- an interruption happened; reset playback{:observe, frame}- a frame of an observed type was pushed (seeobserve/2)
An Octoroom.Agent.Frames.UpdateStage frame goes to the handle_update/2
of the stage it names, not its handle_frame/3, and goes no further. A
stage without handle_update/2 reports an error instead. One that names
no stage here leaves the pipeline like any other frame.
Task and timer ids are opaque. The core drops reports for ids it no longer knows, so the host doesn't have to track generations.
Summary
Functions
Reports a message from a task started with {:start_task, id, fun}.
Delivers a message to handle_info/2.
Validates the spec and initializes every processor. ctx is merged into
each processor's init/2 context; pass runner: pid to give processors a
:reply_to for Octoroom.Agent.Processor.send_to/2. ctx[:telemetry] is added
to telemetry metadata (the runner puts the session id there).
Emits {:observe, frame} whenever a frame of one of modules is pushed.
Pushes a frame into the first stage (downstream) or the last (upstream).
Sets a key in the telemetry metadata carried on every event emitted by this core.
The index of stage name, or nil.
The stage names, in order.
The current state of stage name (for tests and debugging).
Calls every processor's terminate/2 and returns the cleanup commands.
Reports that a timer started with {:start_timer, id, ms} fired.
Types
Functions
Reports a message from a task started with {:start_task, id, fun}.
Delivers a message to handle_info/2.
target is a stage name, a path of stage names into composite stages
(as in ctx.reply_to), or :broadcast for every stage. Broadcast is for
messages from processes that can't address one stage, such as STT sockets
started with the runner as their parent.
@spec new(Octoroom.Agent.Pipeline.Spec.t(), map()) :: {:ok, t()} | {:error, term()}
Validates the spec and initializes every processor. ctx is merged into
each processor's init/2 context; pass runner: pid to give processors a
:reply_to for Octoroom.Agent.Processor.send_to/2. ctx[:telemetry] is added
to telemetry metadata (the runner puts the session id there).
@spec observe(t(), Enumerable.t()) :: t()
Emits {:observe, frame} whenever a frame of one of modules is pushed.
Pushes a frame into the first stage (downstream) or the last (upstream).
Sets a key in the telemetry metadata carried on every event emitted by this core.
The index of stage name, or nil.
The stage names, in order.
The current state of stage name (for tests and debugging).
Calls every processor's terminate/2 and returns the cleanup commands.
Reports that a timer started with {:start_timer, id, ms} fired.