Module orbit
Orbit: A lightweight coroutine-native flow runtime for Lua.
Class Node
| Node:__shr (other) | Syntax sugar for defining linear flows using the >> operator. |
| Node:new (fn, opts) | Creates a new Node. |
| Node:run (shared, item) | Runs the node with retry logic. |
| Node:run_once (shared, item) | Runs the node function once. |
| Node:to (action, target) | Sets the next node for a given action. |
| node:async (start, shared, params) | Creates a coroutine for running a flow asynchronously. |
| node:await (co) | Resumes a flow coroutine. |
| node:batch (fn, opts) | Creates a batch node. |
| node:node (fn, opts) | Creates a standard flow node. |
| node:run (start, shared, params) | Runs a flow from a start node. |
Class Node
The Node class representing a single step in a flow.
- Node:__shr (other)
-
Syntax sugar for defining linear flows using the >> operator.
Parameters:
- other Node The target node.
Returns:
-
Node The target node.
- Node:new (fn, opts)
-
Creates a new Node.
Parameters:
- fn function The function to execute. (shared, item, params)
- opts table? Options for the node.
- retries number? Number of retries (default 1).
- wait number? Seconds to wait between retries (default 0).
- params table? Static parameters for the node.
- batch boolean? Whether this is a batch node.
Returns:
-
Node
- Node:run (shared, item)
-
Runs the node with retry logic.
Parameters:
- shared table The shared state.
- item any? The current item (for batch nodes).
Returns:
-
any The result of the function call.
- Node:run_once (shared, item)
-
Runs the node function once.
Parameters:
- shared table The shared state.
- item any? The current item (for batch nodes).
Returns:
-
any The result of the function call.
- Node:to (action, target)
-
Sets the next node for a given action.
Parameters:
- action string? The action name (default "default").
- target Node The target node to transition to.
Returns:
-
Node The target node (allows chaining).
- node:async (start, shared, params)
-
Creates a coroutine for running a flow asynchronously.
Parameters:
- start Node The starting node.
- shared table? Initial shared state.
- params table? Static parameters.
Returns:
-
thread The coroutine.
- node:await (co)
-
Resumes a flow coroutine.
Parameters:
- co thread The coroutine to resume.
Returns:
-
any The result of the yield or final return.
- node:batch (fn, opts)
-
Creates a batch node.
Batch nodes run twice:
1. Without an item, to generate a list of items.
2. Once for each item generated.
Parameters:
- fn function The function to execute.
- opts table? Options.
Returns:
-
Node
- node:node (fn, opts)
-
Creates a standard flow node.
Parameters:
- fn function The function to execute. (shared, item, params)
- opts table? Options.
Returns:
-
Node
- node:run (start, shared, params)
-
Runs a flow from a start node.
Parameters:
- start Node The starting node.
- shared table? Initial shared state.
- params table? Static parameters for all nodes.
Returns:
-
any The final action returned by the last node.