Documentation
¶
Overview ¶
Package workflow runs dynamic, multi-step workflows over the togo queue.
A workflow is an ordered list of steps; each step has a TYPE that maps to a registered handler (StepFunc). Any plugin can register step types via RegisterStep, so a workflow uses other plugins as providers (send a mail, charge a payment, call an AI model, …). Steps run asynchronously through the kernel Queue, so long pipelines never block a request; shared State is passed between steps in a run.
Index ¶
Constants ¶
const ( StatusPending = "pending" StatusRunning = "running" StatusDone = "done" StatusFailed = "failed" )
Status values for a Run.
Variables ¶
This section is empty.
Functions ¶
func RegisterStep ¶
RegisterStep registers a step type → handler (call from init() or a plugin's Boot). Other plugins register step types so workflows can use them.
Types ¶
type Run ¶
type Run struct {
ID string `json:"id"`
Workflow string `json:"workflow"`
Step int `json:"step"`
Status string `json:"status"`
State map[string]any `json:"state"`
Error string `json:"error,omitempty"`
Started time.Time `json:"started"`
}
Run is a single execution of a workflow.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the workflow runtime stored on the kernel (k.Get("workflow")).
func FromKernel ¶
FromKernel fetches the workflow service from the kernel container.
func (*Service) Definitions ¶
Definitions lists the registered workflow names.
type Step ¶
type Step struct {
Type string `json:"type"` // a registered step type
Name string `json:"name,omitempty"` // optional label
With map[string]any `json:"with,omitempty"` // step parameters
}
Step is one node in a workflow.
type StepContext ¶
type StepContext struct {
Kernel *togo.Kernel
Run *Run
// Next overrides the next step index; -1 ends the run early. Zero value
// (unset) advances to the following step.
Next *int
}
StepContext is passed to a step handler.