Skip to content
Registry

state

v0.22.19

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

license: Apache-2.0Used in 1 kitcachedistributedkey-valuekvstate

Install

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

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

Functions12

state::barrier

Function

Fan-in gate for a binding condition: record one arrival and answer `skip` until the expected set has arrived, then `allow` exactly once carrying every arrival's payload.

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`); a pointer that resolves to nothing is an error.

    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 own worker name only): its scopes leave public state::* and trigger fan-out, and `<prefix>::state::{get, list, compare-and-set}` accessors are registered. Idempotent.

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 the stored value, so the caller can recompute and retry.

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 the value stored at a key in a state scope

Request
  • keystringrequired

    Identifier for the value to delete within the scope.

  • scopestringrequired

    Namespace that groups related keys.

Response
valuestring

state::get

Function

Read the value stored at a key in a state scope

Request
  • keystringrequired

    Identifier for the value within the scope.

  • scopestringrequired

    Namespace that groups related keys.

Response
valuestring

state::list

Function

List every value stored in a state scope

Request
  • scopestringrequired

    Namespace whose keys should be listed as a group.

Response
valuestring

state::list_groups

Function

List all state scopes (groups) that hold values

Request
Empty object
Response
  • groupsstring[]required

state::list_keys

Function

List the keys stored in a state 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

Store or write a value at a key in a state scope; it persists across sessions

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

    Previous value (if it existed).

state::ui-content

Function

Serve the state worker's injected console UI assets (content function for its console:script / console:style / console:module 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 part of a stored value: set, merge, increment, append or remove fields

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

    Previous value (if it existed).

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.