Skip to content
Registry

state

v0.21.6

Distributed key-value state management with reactive change triggers — registers the `state` trigger type and the `state::*` functions.

Install

bash
iii trigger compose::add worker=state@0.21.6

Run in your project with the iii engine running. Exact versions are immutable and digest-pinned.

Functions12

state::barrier

Function

Fan-in gate: record one arrival against a barrier and answer the typed condition decision — `skip` until the expected set has arrived, then `allow` EXACTLY ONCE carrying every arrival's payload. Use as a binding condition so a coordinator wakes once when N producers finish instead of once per producer.

Request
  • condition_configany of
    any of (2)
    Variant 1
    • carrystring

      JSON pointer into the event for the value to accumulate (default: the whole event).

    • expectall ofrequired

      A count, or the exact set of arrival keys.

      Show 1 nested
      all of (1)
      Variant 1
      any of (2)
      Variant 1
      valueinteger· uint641…10000
      Variant 2
      itemsstring[]
    • idstringrequired

      Barrier identity. Two bindings sharing an id share the barrier — that is how several predecessors feed one downstream.

    • key_fromstring

      JSON pointer into the event for the arrival key (default `/key`, the state event's own key). A missing pointer is an error, not a silent unnamed arrival: two arrivals that both resolve to nothing would collapse into one and the barrier would never complete.

    Variant 2
    valuenull
  • eventunknown
Response
one of (2)
Variant 1
  • decisionstringrequiredenum allow
  • payloadunknown
  • reasonstringrequired
Variant 2
  • decisionstringrequiredenum skip
  • reasonstringrequired

state::claim-namespace

Function

Reserve a PRIVATE state namespace for the calling worker: its scopes become invisible to public state::* and to trigger fan-out, and internal accessors `<functions_prefix>::state::{get, list, compare-and-set}` are registered. A worker may only claim the namespace matching its own worker name (engine-stamped caller identity). Idempotent; claims survive a state restart.

Request
  • _caller_worker_idstring
  • functions_prefixstringrequired

    Must equal the calling worker's name.

  • scopesstring[]required

    Storage scopes to reserve for this namespace.

Response
  • claimedbooleanrequired

    False when the namespace already owned everything asked for.

  • functionsstring[]required

    The accessor ids now serving this namespace.

  • scopesstring[]required

    Every scope this namespace owns after the call.

state::compare-and-set

Function

Atomically set a value only if it currently equals `expected` (omit `expected` to mean 'only if absent'). Returns { swapped, current } — on a miss, `current` is what is actually there, so a caller can recompute and retry. The primitive for counters, claims and any read-modify-write that two callers might race.

Request
  • expectedunknown

    The value the caller believes is there. Omit to mean "expect absent" — the set-if-absent form.

  • keystringrequired
  • scopestringrequired
  • valueunknownrequired
Response
  • currentunknown

    What is actually stored, when the swap did not happen.

  • swappedbooleanrequired

state::delete

Function

Delete a value from state

Request
  • keystringrequired

    Identifier for the value to delete within the scope.

  • scopestringrequired

    Namespace that groups related keys.

Response
valuestring

state::get

Function

Get a value from state

Request
  • keystringrequired

    Identifier for the value within the scope.

  • scopestringrequired

    Namespace that groups related keys.

Response
valuestring

state::list

Function

Get a group from state

Request
  • scopestringrequired

    Namespace whose keys should be listed as a group.

Response
valuestring

state::list_groups

Function

List all state groups

Request
Empty object
Response
  • groupsstring[]required

state::list_keys

Function

List the keys stored in a scope

Request
  • scopestringrequired

    Namespace whose keys should be listed as a group.

Response
  • keysstring[]required

    Keys stored in the scope, in the adapter's natural order.

state::on-config-change

Function

Internal: reload state configuration from the authoritative store on change.

Request
Empty object
Response
  • okbooleanrequired

state::set

Function

Set a value in state

Request
  • keystringrequired

    Identifier for the value within the scope.

  • scopestringrequired

    Namespace that groups related keys (e.g. `users`, `orders`).

  • valueunknownrequired

    Arbitrary JSON value to store. Replaces any existing value at `scope`/`key`.

Response
  • new_valueunknownrequired

    The value after the update

  • old_valueunknown

    The value before the update (None if key didn't exist)

state::ui-content

Function

Serve the state worker's injected console UI assets (content function for its console:script / console:style triggers).

Request
  • pathstringrequired

    The asset path from the trigger config (e.g. `state/page.js`).

Response
  • contentstringrequired

    The asset source, verbatim.

  • content_typestringrequired

    MIME type the console should serve the asset with.

state::update

Function

Update a value in state

Request
  • keystringrequired

    Identifier for the value to update within the scope.

  • opsone of[]required

    Ordered list of update operations applied atomically to the existing value.

    one of (6)
    Variant 1
    • pathstringrequired
    • typestringrequiredenum set
    • valueunknown
    Variant 2
    • pathany of
      Show 2 nested
      any of (2)
      Variant 1
      any of (2)
      Variant 1
      valuestring
      Variant 2
      itemsstring[]
      Variant 2
      valuenull
    • typestringrequiredenum merge
    • valueunknownrequired
    Variant 3
    • byinteger· int64required
    • pathstringrequired
    • typestringrequiredenum increment
    Variant 4
    • byinteger· int64required
    • pathstringrequired
    • typestringrequiredenum decrement
    Variant 5
    • pathany of
      Show 2 nested
      any of (2)
      Variant 1
      any of (2)
      Variant 1
      valuestring
      Variant 2
      itemsstring[]
      Variant 2
      valuenull
    • typestringrequiredenum append
    • valueunknownrequired
    Variant 6
    • pathstringrequired
    • typestringrequiredenum remove
  • scopestringrequired

    Namespace that groups related keys.

Response
  • errorsobject[]

    Errors encountered while applying ops. Successfully applied ops are still reflected in `new_value`. Field is omitted from JSON when empty for backward compatibility.

    • codestringrequired

      Stable error code, e.g. `"merge.path.too_deep"`.

    • doc_urlstring

      Optional documentation URL for this error class.

    • messagestringrequired

      Human-readable description with concrete numbers when applicable.

    • op_indexinteger· uintrequiredmin 0

      Index of the offending op within the original `ops` array.

  • new_valueunknownrequired

    The value after the update

  • old_valueunknown

    The value before the update (None if key didn't exist)

Triggers1

state

Trigger

State trigger

Invocation
  • condition_function_idstring

    Optional function evaluated per event; only an explicit `false` skips.

  • keystring

    Only fire for writes to this key (any key when unset).

  • scopestring

    Only fire for writes in this scope (any scope when unset).

Return
  • event_typeall ofrequired

    Type of state change

    all of (1)
    Variant 1
    valuestringenum state:created, state:updated, state:deleted
  • keystringrequired

    State key

  • new_valueunknownrequired

    New value

  • old_valueunknown

    Previous value (null for created events)

  • scopestringrequired

    State scope

  • typestringrequired

    Always "state"

Search the registry

Find workers, kits and executables, or jump to a page.