Documentation
¶
Overview ¶
Package dwarf is a standalone, embeddable workflow-orchestration engine.
Dwarf executes workflow graphs: it dispatches tasks, manages state between steps, and handles fan-out/fan-in, retries, sleeps, conditional routing, subgraphs, and human-in-the-loop interrupts. It is library code with no built-in transport: a host application wires it to its own task execution, graph storage, and observability through a small set of injected dependency interfaces (see the engine package). It depends only on a SQL database (via sequel).
This root package is a thin convenience: NewEngine returns an *engine.Engine. The real API lives in two sub-packages:
- github.com/microbus-io/dwarf/engine - the engine: Startup/Shutdown, the Create/Run/Await operations, configuration, and the dependency interfaces. Import this only in the process that hosts the engine.
- github.com/microbus-io/dwarf/workflow - the pure types: Graph, Flow, FlowOptions, FlowOutcome, and reducers. Import this in code that defines tasks and graphs; it has no heavy dependencies.
A 30-second taste, using the in-process test harness:
proxy := engine.NewTestProxy()
g := workflow.NewGraph("Greet")
g.SetEndpoint("Hello", "http://example/hello") // node "Hello" dispatches to this endpoint URL
g.AddTransition("Hello", workflow.END)
proxy.HandleGraph("http://example/greet", g)
proxy.HandleTask("http://example/hello", func(ctx context.Context, f *workflow.Flow) error {
f.SetString("greeting", "hello "+f.GetString("name"))
return nil
})
eng := dwarf.NewEngine()
eng.SetHost(proxy)
eng.RunInTest(t) // SQLite in-memory, auto cleanup
_, out, _ := eng.Run(ctx, "http://example/greet", map[string]any{"name": "ada"}, nil)
fmt.Println(out.State["greeting"]) // hello ada
See the docs/ directory in the repository for guides on graphs, tasks, scheduling, observability, and deployment.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package engine is the dwarf workflow-orchestration engine.
|
Package engine is the dwarf workflow-orchestration engine. |
|
internal
|
|
|
candidatecache
Package candidatecache holds the per-replica bounded set of step candidates produced by the engine's refiller.
|
Package candidatecache holds the per-replica bounded set of step candidates produced by the engine's refiller. |
|
database
Package database owns the engine's sharded SQL connections: it opens and migrates every shard, routes by 1-based shard index, fans an operation out over all shards, and closes them.
|
Package database owns the engine's sharded SQL connections: it opens and migrates every shard, routes by 1-based shard index, fans an operation out over all shards, and closes them. |
|
keys
Package keys encodes and decodes the engine's composite flow and step keys.
|
Package keys encodes and decodes the engine's composite flow and step keys. |
|
lru
Package lru provides a small thread-safe LRU cache with a per-entry TTL.
|
Package lru provides a small thread-safe LRU cache with a per-entry TTL. |
|
Package workflow holds the pure data types of the dwarf workflow engine: the building blocks a host uses to define workflows and the carriers it reads and writes when running tasks.
|
Package workflow holds the pure data types of the dwarf workflow engine: the building blocks a host uses to define workflows and the carriers it reads and writes when running tasks. |