Node
junjo.Node
Kind: Class
SDK version: 0.64.0
Documentation channel: Next source preview
Signature
Section titled “Signature”Node()Nodes are the building blocks of a workflow. They represent a single unit of work that can be executed within the context of a workflow.
Place business logic to be executed by the node in service. Junjo
wraps that service method with OpenTelemetry tracing, error handling, and
lifecycle hook dispatch during execute.
The Node type is meant to remain decoupled from your application’s
domain logic. While you can place business logic directly in the
service method, it is recommended that you call a service function
located in a separate module. This keeps nodes easy to test, easier to
understand, and focused on orchestration rather than implementation detail.
StoreT is the workflow store type that will be passed into this node
during execution.
Nodes have three main responsibilities:
- The workflow passes the run-local store to the node’s
executemethod. executemanages tracing, lifecycle hooks, and error handling.serviceperforms the side effects for this unit of work.
.. rubric:: Example implementation
python class SaveMessageNode(Node[MessageWorkflowStore]): async def service(self, store) -> None: state = await store.get_state() sentiment = await get_message_sentiment(state.message) await store.set_message_sentiment(sentiment)
Members
Section titled “Members”id: strReturns the unique identifier for the node.
name: strReturns the name of the node class instance.
service
Section titled “service”service(store: StoreT) -> NoneThis is the main logic of the node.
The concrete implementation of this method should contain the side
effects that this node will perform. The method is called by
execute, which is responsible for tracing, lifecycle dispatch,
and error handling.
The service method should not be called directly. Instead, it
should be called by the execute method of the node.
DO NOT EXECUTE node.service() DIRECTLY!
Use node.execute() instead.
Parameters
Section titled “Parameters”| Name | Type | Description | Default |
|---|---|---|---|
store |
StoreT |
The run-local store passed to the node’s service function. |
execute
Section titled “execute”execute(store: StoreT, parent_id: str) -> NoneExecute the node’s service method with tracing and lifecycle
dispatch.
This method acquires a tracer, opens a node span, emits lifecycle
events, and then calls service. Terminal lifecycle hooks are
dispatched before the span closes so hook failure telemetry can stay
attached to the real node span.
Parameters
Section titled “Parameters”| Name | Type | Description | Default |
|---|---|---|---|
store |
StoreT |
The run-local store for the current workflow execution. | |
parent_id |
str |
The identifier of the parent workflow or subflow. This becomes the parent id recorded on the node span. |