examples/

directory
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: Apache-2.0

README

Packtrail examples

Each example is a self-contained main package with its own flow definitions and NATS namespace, so they can run against the same server without colliding. All of them need a reachable NATS Server 2.12+ with JetStream enabled:

nats-server -js

Run the examples from the repo root (two of them load flow YAML from a relative flows/ directory) and pass --nats if the server is not on nats://127.0.0.1:4222.

Example Namespace Shows
embedded acme Engine + built-in nats-task workers in one process: WithFlowsDir, Server.Handle, fanout/fanin, a signal gate, reconcile schedules, Server.Results.
worker packtrail A standalone external task service speaking pkg/protocol — no engine import. Run it next to embedded (same --namespace) and the two load-balance the same subjects via the shared queue group.
custom-invoker agents The pluggable Invoker seam: WithInvoker("agent", …) drives task nodes by target name, a choice node routes on the triage agent's output (results.triage.category), WithResultCache dedupes redelivered side effects.
async async-demo Long-running work off the critical path: WithAsyncInvoker + invoker/asyncqueue run slow fanout branches on a durable work-queue while the execution parks as waiting; flow built as a Go-struct FlowDef.
approval orders Human-in-the-loop: a signal node with an on_timeout fallback, Server.Signal to approve, Server.Cancel to abandon, and WithHistory + Server.History for the durable step-by-step trace.
go run ./examples/embedded        # engine + in-process workers, one execution
go run ./examples/worker         --namespace acme   # optional: external workers for the run above
go run ./examples/custom-invoker  # two executions routed by a simulated agent
go run ./examples/async           # slow branches on the async work-queue
go run ./examples/approval        # one approved order, one cancelled order

To watch any of them in the dashboard, point packtrail-ui at the example's namespace:

go run ./cmd/packtrail-ui --namespace agents --addr :8088

Directories

Path Synopsis
Command approval demonstrates human-in-the-loop control: a signal node parks the execution until an external approval arrives (with a timeout fallback), Cancel abandons an execution an operator no longer wants, and WithHistory records a durable step-by-step trace queryable with Server.History.
Command approval demonstrates human-in-the-loop control: a signal node parks the execution until an external approval arrives (with a timeout fallback), Cancel abandons an execution an operator no longer wants, and WithHistory records a durable step-by-step trace queryable with Server.History.
Command async demonstrates long-running work off the engine's critical path.
Command async demonstrates long-running work off the engine's critical path.
Command custom-invoker demonstrates packtrail's defining feature: the pluggable Invoker seam.
Command custom-invoker demonstrates packtrail's defining feature: the pluggable Invoker seam.
Command embedded shows packtrail running as a single microservice: the engine and the task workers live in one process, importing only the public github.com/henomis/packtrail package.
Command embedded shows packtrail running as a single microservice: the engine and the task workers live in one process, importing only the public github.com/henomis/packtrail package.
Command worker is a tiny external task service for the research-pipeline flow, demonstrating the pkg/protocol request/reply contract without importing the packtrail engine at all.
Command worker is a tiny external task service for the research-pipeline flow, demonstrating the pkg/protocol request/reply contract without importing the packtrail engine at all.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL