src/pocketflow/context

Search:
Group by:

Context module for PocketFlow

Provides a shared context for passing data between nodes in a flow. The context stores JSON data in a key-value table.

Types

PfContext = ref object
  store*: TableRef[string, JsonNode]
Shared context for flow execution. Stores arbitrary JSON data that can be accessed by any node in the flow.

Procs

proc `[]`(ctx: PfContext; key: string): JsonNode {....raises: [KeyError], tags: [],
    forbids: [].}

Gets a value from the context by key.

Args: key: The key to look up

Returns: The JSON value associated with the key, or JNull if key doesn't exist

proc `[]=`(ctx: PfContext; key: string; value: JsonNode) {....raises: [], tags: [],
    forbids: [].}

Sets a value in the context.

Args: key: The key to set value: The JSON value to store

proc hasKey(ctx: PfContext; key: string): bool {....raises: [], tags: [],
    forbids: [].}

Checks if a key exists in the context.

Args: key: The key to check

Returns: True if the key exists, false otherwise

proc newPfContext(): PfContext {....raises: [], tags: [], forbids: [].}

Creates a new PocketFlow context.

Returns: A new PfContext instance with an empty data table.