ablative docs
↑↓ move↵ openesc close
Stack Notebook ablative.com.au

AWL signals and queries

Declare sent and received signals and expose typed live query answers.

Open .md

Sending

send awl 12

Declares an outbound signal in the header, and in a step body sends it to another running workflow.

  • form statement
  • positions workflow-header, workloop-header, step-body
//! Signal another running workflow, addressed by its durable id.
workflow report_progress
  input coordinator_id: String
  input item: String
  send progress: Progress
  outcome done: type String, route success

type Progress { item: String, state: String }

step announce
  send progress(item: item, state: "started") to coordinator_id
  route done(item)
to awl 12

Addresses the target of a `send`: a workflow id, which is a `String`.

  • form target-word
  • positions signal-reference
//! `to` addresses the target: a workflow id, which is a String.
workflow notify_parent
  input parent_id: String
  input item: String
  send finished: String
  outcome done: type String, route success

step notify
  send finished("done: " + item) to parent_id
  route done(item)

The header declares each sent signal’s type. A send supplies named record fields, a typed value, or no payload for Nil. The target must use the supported workflow or child form; address workflows by their ids.

Received signals are declared in the workflow header and consumed by wait.

Live answers

query awl 13

Declares what an operator may ask a running instance, and the type of the answer they receive.

  • form header-clause
  • positions workflow-header, workloop-header
//! `query` declares what an operator may ask a running instance.
workflow track_import
  input dataset: String
  query phase: String
  outcome done: type String, route success

step ingest
  answer phase("ingesting " + dataset)
  route done(dataset)
answer awl 13

Registers the value a declared query returns, computed from the bindings in scope where it stands.

  • form statement
  • positions step-body
//! `answer` registers the value a declared query returns.
workflow watch_backup
  input volume: String
  query progress: String
  outcome done: type String, route success

step copy
  answer progress("copying " + volume)
  route done(volume)

Each answer names a declared query and matches its return type. Re-registering an answer updates the value an operator can read. Every declared query must have an answer somewhere in the source.

That last check is syntactic. An answer in unreachable code satisfies it, as can an answer in a per-item child that is invisible on the parent. Place the answer on the actual parent path where the operator needs it.

A terminal run no longer answers live queries. Read describe and history for its recorded result. Schema’s queries mode emits the answer schemas.