Documentation
¶
Overview ¶
Package pipeline provides the event-driven pipeline execution engine.
Package pipeline provides the event-driven pipeline execution engine.
Index ¶
- Constants
- Variables
- func BindBlueprintInputs(defs []BlueprintInputDef, provided map[string]any) (map[string]any, error)
- func BuiltinBlueprintIDs() (map[string]struct{}, error)
- func ContentHash(yamlBytes []byte) string
- func InjectAgentRunDefaults(step Step, renderedParams map[string]any, rc *RenderContext, ...)
- func IsEnabledInYAML(yamlStr string) bool
- func IsTerminalProgressJSON(data string) bool
- func LooksLikeBlueprint(yamlBytes []byte) bool
- func MarshalBlueprintYAML(doc *BlueprintDocument) ([]byte, error)
- func MaterializeEditorYAML(doc *BlueprintDocument, instanceName string, enabled bool, ...) (string, error)
- func MissingCapabilities(requires []string) []string
- func ReloadDefinitions(ctx context.Context) error
- func RunBelongsToParent(pipelineName, parent string) bool
- func SetActiveBlueprintService(svc *BlueprintService)
- func SetActiveEngine(engine *Engine)
- func SetActiveService(svc *Service)
- func SetEnabledInYAML(yamlStr string, enabled bool) (string, error)
- func SetNameInYAML(yamlStr, name string) (string, error)
- func SetReloadSource(source DefinitionSource, engine *Engine)
- func StepResultFromInvoke(res *capability.InvokeResult) map[string]any
- func StreamName(runID int64) string
- func ValidateBlueprintID(id string) error
- func ValidateName(name string) error
- type ApplyResult
- type BlueprintCatalogEntry
- type BlueprintDocument
- type BlueprintInputDef
- type BlueprintLibrary
- type BlueprintOrigin
- type BlueprintOriginStore
- type BlueprintRequires
- type BlueprintService
- func (s *BlueprintService) ConfirmInstanceUpdate(ctx context.Context, pipelineName string) (*model.PipelineDefinition, error)
- func (s *BlueprintService) DeleteUserTemplate(ctx context.Context, blueprintID string) error
- func (s *BlueprintService) ImportYAML(ctx context.Context, yamlBytes []byte, createdBy string) (*BlueprintTemplateRecord, error)
- func (s *BlueprintService) InstanceUpdateAvailable(ctx context.Context, def *model.PipelineDefinition) (bool, error)
- func (s *BlueprintService) Instantiate(ctx context.Context, req InstantiateRequest) (*model.PipelineDefinition, error)
- func (s *BlueprintService) ListCatalog(ctx context.Context) ([]BlueprintCatalogEntry, error)
- func (s *BlueprintService) ReplaceYAML(ctx context.Context, blueprintID string, yamlBytes []byte) (*BlueprintTemplateRecord, error)
- func (s *BlueprintService) ResolveTemplate(ctx context.Context, source, id string) (*BlueprintCatalogEntry, error)
- func (s *BlueprintService) TakeControl(ctx context.Context, pipelineName string) error
- func (s *BlueprintService) UpdateInstanceInputs(ctx context.Context, pipelineName string, inputs map[string]any, enable *bool) (*model.PipelineDefinition, error)
- type BlueprintTemplateRecord
- type BuiltinBlueprint
- type CheckpointData
- type Clock
- type Definition
- func ExpandDefinitions(defs []EditorDefinition) []Definition
- func FindByEvent(defs []Definition, eventType string) []Definition
- func FindDefsByParentName(defs []Definition, parentName string) []Definition
- func LoadConfig(cfg []config.Pipeline) []Definition
- func LoadFromDB(ctx context.Context, reader DefinitionReader) ([]Definition, error)
- func SelectManualDef(defs []Definition, parentName, eventType string) (*Definition, error)
- type DefinitionCatalog
- type DefinitionReader
- type DefinitionRecord
- type DefinitionSource
- type EditorDefinition
- type Engine
- func (e *Engine) ExecuteManual(ctx context.Context, parentName string, event types.DataEvent) (int64, error)
- func (e *Engine) ExecuteWebhook(ctx context.Context, def *Definition, event types.DataEvent) error
- func (e *Engine) Handler() func(ctx context.Context, event types.DataEvent) error
- func (e *Engine) LookupWebhook(path string) (*Definition, bool)
- func (e *Engine) MutexFor(name string) *sync.Mutex
- func (e *Engine) RegisterWebhooks() (map[string]*Definition, error)
- func (e *Engine) Reload(defs []Definition) error
- func (e *Engine) ResumePipeline(ctx context.Context, runID int64) error
- func (e *Engine) RetryFailedRun(ctx context.Context, runID int64, event types.DataEvent) error
- func (e *Engine) SetCallback(cb StepCallback)
- func (e *Engine) Stop()
- type FakeClock
- type InstantiateRequest
- type ListInfo
- type RealClock
- type RenderContext
- type RunStore
- type Service
- func (s *Service) ApplyYAML(ctx context.Context, data []byte, createdBy string) (*ApplyResult, error)
- func (s *Service) Delete(ctx context.Context, name string) error
- func (s *Service) Export(ctx context.Context, name string) (string, error)
- func (s *Service) Get(ctx context.Context, name string) (map[string]any, error)
- func (s *Service) List(ctx context.Context) ([]ListInfo, error)
- func (s *Service) ListRuns(ctx context.Context, name string) ([]*model.PipelineRun, error)
- func (s *Service) StartRunAsync(ctx context.Context, name string, eventData map[string]any, uid string) (int64, error)
- type Step
- type StepCallback
- type StepProgressEvent
- type StepResult
- type Trigger
- type TriggerEntry
- type WebhookAuthConfig
- type WebhookConfig
Constants ¶
const ( BlueprintSourceBuiltin = "builtin" BlueprintSourceUpload = "upload" )
Origin sources for a linked pipeline instance.
const ( BlueprintInputString = "string" BlueprintInputNumber = "number" BlueprintInputBoolean = "boolean" BlueprintInputNotifyChannel = "notify_channel" )
Closed set of blueprint input types.
const KindPipelineBlueprint = "pipeline_blueprint"
Blueprint document kind stored in YAML.
const StreamTTLDrain = 5 * time.Minute
StreamTTLDrain is the TTL after completion for SSE clients to drain.
const StreamTTLFailsafe = 24 * time.Hour
StreamTTLFailsafe is the TTL set on stream creation to prevent leaks on crash.
Variables ¶
var ( // ErrRetryNotFailed is returned when RetryFailedRun is called on a non-failed run. ErrRetryNotFailed = errors.New("pipeline run is not failed") // ErrRetryDefMissing is returned when the run's pipeline is not in the loaded published defs. ErrRetryDefMissing = errors.New("pipeline definition is not loaded") // ErrRetryStepMissing is returned when the failed step name is gone from the published YAML. ErrRetryStepMissing = errors.New("failed step is not in the published definition") )
Sentinel errors for failed-run retry so HTTP handlers can map toasts without string matching.
var BlueprintIDPattern = regexp.MustCompile(`^[a-z][a-z0-9_]{0,63}$`)
BlueprintIDPattern matches a stable blueprint identifier.
var NamePattern = types.PipelineNamePattern
NamePattern matches valid pipeline names.
Functions ¶
func BindBlueprintInputs ¶
BindBlueprintInputs merges defaults with provided values and type-checks them.
func BuiltinBlueprintIDs ¶
BuiltinBlueprintIDs returns the set of official blueprint ids.
func ContentHash ¶
ContentHash returns the SHA-256 hex digest of blueprint YAML bytes.
func InjectAgentRunDefaults ¶ added in v0.95.0
func InjectAgentRunDefaults(step Step, renderedParams map[string]any, rc *RenderContext, pipelineName string)
InjectAgentRunDefaults applies default uid and memory_scope for agent_run and notify_send steps.
func IsEnabledInYAML ¶ added in v0.95.0
IsEnabledInYAML reports whether a pipeline definition YAML is active. Missing or unparseable enabled fields default to true.
func IsTerminalProgressJSON ¶ added in v0.99.0
IsTerminalProgressJSON reports whether progress JSON is a run-level terminal event (complete/failed) without unmarshaling Input/Output payloads.
func LooksLikeBlueprint ¶
LooksLikeBlueprint reports whether YAML declares kind: pipeline_blueprint.
func MarshalBlueprintYAML ¶
func MarshalBlueprintYAML(doc *BlueprintDocument) ([]byte, error)
MarshalBlueprintYAML serializes a blueprint document.
func MaterializeEditorYAML ¶
func MaterializeEditorYAML(doc *BlueprintDocument, instanceName string, enabled bool, inputs map[string]any) (string, error)
MaterializeEditorYAML substitutes {{inputs.*}} into the blueprint definition and returns a published EditorDefinition YAML for the given instance name and enabled flag.
func MissingCapabilities ¶
MissingCapabilities returns required capability types that are not registered on the hub.
func ReloadDefinitions ¶ added in v0.95.0
ReloadDefinitions reloads the pipeline engine from the configured source.
func RunBelongsToParent ¶ added in v0.99.8
RunBelongsToParent reports whether a run's engine name is the parent pipeline or a compound trigger name (parent__trigger_*).
func SetActiveBlueprintService ¶
func SetActiveBlueprintService(svc *BlueprintService)
SetActiveBlueprintService wires the package-level blueprint service.
func SetActiveEngine ¶ added in v0.99.0
func SetActiveEngine(engine *Engine)
SetActiveEngine wires the package-level Engine used by ActiveEngine and ExecuteManual callers.
func SetActiveService ¶ added in v0.99.0
func SetActiveService(svc *Service)
SetActiveService wires the package-level Service used by HTTP modules.
func SetEnabledInYAML ¶ added in v0.95.0
SetEnabledInYAML returns YAML with the top-level enabled field updated. Cron triggers are synced so pause also stops scheduled runs after engine reload.
func SetNameInYAML ¶ added in v0.98.1
SetNameInYAML returns YAML with the top-level name field updated.
func SetReloadSource ¶ added in v0.95.0
func SetReloadSource(source DefinitionSource, engine *Engine)
SetReloadSource wires the definition loader and engine used by ReloadDefinitions.
func StepResultFromInvoke ¶ added in v0.95.0
func StepResultFromInvoke(res *capability.InvokeResult) map[string]any
StepResultFromInvoke converts an ability invoke result into a step output map for templates.
func StreamName ¶
StreamName returns the Redis Stream name for a given run ID.
func ValidateBlueprintID ¶
ValidateBlueprintID reports whether id is a valid blueprint identifier.
func ValidateName ¶ added in v0.96.0
ValidateName reports whether name is a valid pipeline identifier.
Types ¶
type ApplyResult ¶ added in v0.99.0
type ApplyResult struct {
Name string `json:"name"`
ID int64 `json:"id"`
Enabled bool `json:"enabled"`
Version int `json:"version"`
}
ApplyResult is returned after applying a pipeline YAML definition.
type BlueprintCatalogEntry ¶
type BlueprintCatalogEntry struct {
Source string
Document BlueprintDocument
YAML string
Hash string
Missing []string
InstanceCount int
UpdateAvailable bool
}
BlueprintCatalogEntry is one card in the template library.
type BlueprintDocument ¶
type BlueprintDocument struct {
Kind string `json:"kind" yaml:"kind"`
ID string `json:"id" yaml:"id"`
Title string `json:"title" yaml:"title"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Requires BlueprintRequires `json:"requires" yaml:"requires,omitempty"`
Inputs []BlueprintInputDef `json:"inputs,omitempty" yaml:"inputs,omitempty"`
Definition map[string]any `json:"definition" yaml:"definition"`
}
BlueprintDocument is the on-disk / import wrapper for a pipeline blueprint.
func ParseBlueprintYAML ¶
func ParseBlueprintYAML(yamlBytes []byte) (*BlueprintDocument, error)
ParseBlueprintYAML parses and validates a pipeline blueprint document.
type BlueprintInputDef ¶
type BlueprintInputDef struct {
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
Default any `json:"default,omitempty" yaml:"default,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
}
BlueprintInputDef declares one instance-configuration parameter.
type BlueprintLibrary ¶
type BlueprintLibrary interface {
ListUserTemplates(ctx context.Context) ([]BlueprintTemplateRecord, error)
GetUserTemplate(ctx context.Context, blueprintID string) (*BlueprintTemplateRecord, error)
UpsertUserTemplate(ctx context.Context, rec BlueprintTemplateRecord) error
DeleteUserTemplate(ctx context.Context, blueprintID string) error
}
BlueprintLibrary persists user-imported blueprint templates.
type BlueprintOrigin ¶
type BlueprintOrigin struct {
Source string `json:"source"`
ID string `json:"id"`
Hash string `json:"hash"`
YAML string `json:"yaml"`
Inputs map[string]any `json:"inputs"`
}
BlueprintOrigin is persisted on a linked pipeline definition.
func OriginFromDefinition ¶
func OriginFromDefinition(def *model.PipelineDefinition) (BlueprintOrigin, bool)
OriginFromDefinition returns origin metadata when the pipeline is still linked.
type BlueprintOriginStore ¶
type BlueprintOriginStore interface {
CreateDefinition(ctx context.Context, name, description, createdBy string) error
GetDefinitionByName(ctx context.Context, name string) (*model.PipelineDefinition, error)
UpdateDefinitionDraft(ctx context.Context, name, yamlDraft string, version int) (*model.PipelineDefinition, error)
PublishDefinition(ctx context.Context, name string, version int) (*model.PipelineDefinition, error)
SetBlueprintOrigin(ctx context.Context, name string, origin BlueprintOrigin) error
ClearBlueprintOrigin(ctx context.Context, name string) error
ListLinkedPipelineNames(ctx context.Context, source, blueprintID string) ([]string, error)
EnsureDefinitionCreatedBy(ctx context.Context, name, createdBy string) error
}
BlueprintOriginStore persists origin metadata on pipeline definitions.
type BlueprintRequires ¶
type BlueprintRequires struct {
Capabilities []string `json:"capabilities,omitempty" yaml:"capabilities,omitempty"`
}
BlueprintRequires lists capabilities the template needs in order to instantiate.
type BlueprintService ¶
type BlueprintService struct {
// contains filtered or unexported fields
}
BlueprintService orchestrates the template library and linked pipeline instances.
func ActiveBlueprintService ¶
func ActiveBlueprintService() *BlueprintService
ActiveBlueprintService returns the wired blueprint service, or nil.
func NewBlueprintService ¶
func NewBlueprintService(library BlueprintLibrary, instances BlueprintOriginStore) *BlueprintService
NewBlueprintService creates a BlueprintService.
func (*BlueprintService) ConfirmInstanceUpdate ¶
func (s *BlueprintService) ConfirmInstanceUpdate(ctx context.Context, pipelineName string) (*model.PipelineDefinition, error)
ConfirmInstanceUpdate rematerializes from the current catalog template using stored inputs.
func (*BlueprintService) DeleteUserTemplate ¶
func (s *BlueprintService) DeleteUserTemplate(ctx context.Context, blueprintID string) error
DeleteUserTemplate removes a user template when no linked instances remain.
func (*BlueprintService) ImportYAML ¶
func (s *BlueprintService) ImportYAML(ctx context.Context, yamlBytes []byte, createdBy string) (*BlueprintTemplateRecord, error)
ImportYAML adds a user template. Ids that collide with official or existing user templates are rejected.
func (*BlueprintService) InstanceUpdateAvailable ¶
func (s *BlueprintService) InstanceUpdateAvailable(ctx context.Context, def *model.PipelineDefinition) (bool, error)
InstanceUpdateAvailable reports whether the catalog template hash differs from the instance.
func (*BlueprintService) Instantiate ¶
func (s *BlueprintService) Instantiate(ctx context.Context, req InstantiateRequest) (*model.PipelineDefinition, error)
Instantiate creates a new linked pipeline instance.
func (*BlueprintService) ListCatalog ¶
func (s *BlueprintService) ListCatalog(ctx context.Context) ([]BlueprintCatalogEntry, error)
ListCatalog returns official plus user templates with instance counts and missing caps.
func (*BlueprintService) ReplaceYAML ¶
func (s *BlueprintService) ReplaceYAML(ctx context.Context, blueprintID string, yamlBytes []byte) (*BlueprintTemplateRecord, error)
ReplaceYAML updates a user template in place. Id in YAML must match.
func (*BlueprintService) ResolveTemplate ¶
func (s *BlueprintService) ResolveTemplate(ctx context.Context, source, id string) (*BlueprintCatalogEntry, error)
ResolveTemplate loads a builtin or user template.
func (*BlueprintService) TakeControl ¶
func (s *BlueprintService) TakeControl(ctx context.Context, pipelineName string) error
TakeControl irreversibly detaches origin from a linked pipeline.
func (*BlueprintService) UpdateInstanceInputs ¶
func (s *BlueprintService) UpdateInstanceInputs(ctx context.Context, pipelineName string, inputs map[string]any, enable *bool) (*model.PipelineDefinition, error)
UpdateInstanceInputs rematerializes a linked pipeline with new input values. When enable is non-nil, the published enabled flag is set to that value.
type BlueprintTemplateRecord ¶
type BlueprintTemplateRecord struct {
BlueprintID string
Title string
Description string
YAML string
Hash string
CreatedBy string
}
BlueprintTemplateRecord is a user-library row.
type BuiltinBlueprint ¶
type BuiltinBlueprint struct {
Document BlueprintDocument
YAML string
Hash string
}
BuiltinBlueprint holds one official catalog YAML and its parsed document.
func LoadBuiltinBlueprints ¶
func LoadBuiltinBlueprints() ([]BuiltinBlueprint, error)
LoadBuiltinBlueprints reads the embedded official catalog.
func LookupBuiltinBlueprint ¶
func LookupBuiltinBlueprint(id string) (*BuiltinBlueprint, error)
LookupBuiltinBlueprint returns the official template with the given id.
type CheckpointData ¶
type CheckpointData struct {
StepIndex int `json:"step_index"`
StepResults map[string]*StepResult `json:"step_results"`
Event types.DataEvent `json:"event"`
HeartbeatAt time.Time `json:"heartbeat_at"`
}
CheckpointData is the intermediate state saved at each pipeline step boundary.
type Definition ¶
type Definition struct {
Name string
Description string
Enabled bool
Resumable bool
// UID is the Web UI creator of this pipeline (from pipeline_definitions.created_by).
// Applied to events when the trigger does not carry a UID (cron/webhook).
UID string
Trigger Trigger
Steps []Step
ParentName string
}
func ExpandDefinitions ¶
func ExpandDefinitions(defs []EditorDefinition) []Definition
ExpandDefinitions fans out an editor definition with multiple triggers into engine Definition instances with compound names to avoid key collisions.
func FindByEvent ¶
func FindByEvent(defs []Definition, eventType string) []Definition
func FindDefsByParentName ¶ added in v0.99.0
func FindDefsByParentName(defs []Definition, parentName string) []Definition
FindDefsByParentName returns loaded engine definitions for a parent pipeline name.
func LoadConfig ¶
func LoadConfig(cfg []config.Pipeline) []Definition
func LoadFromDB ¶
func LoadFromDB(ctx context.Context, reader DefinitionReader) ([]Definition, error)
LoadFromDB loads published pipeline definitions from a DefinitionReader.
func SelectManualDef ¶ added in v0.99.0
func SelectManualDef(defs []Definition, parentName, eventType string) (*Definition, error)
SelectManualDef chooses one loaded definition for a manual run. When eventType is set, prefers an event trigger matching that type; otherwise the first match.
func (Definition) FindByEvent ¶
func (d Definition) FindByEvent(eventType string) []Definition
type DefinitionCatalog ¶ added in v0.99.0
type DefinitionCatalog interface {
CreateDefinition(ctx context.Context, name, description, createdBy string) error
GetDefinitionByName(ctx context.Context, name string) (*model.PipelineDefinition, error)
UpdateDefinitionDraft(ctx context.Context, name, yamlDraft string, version int) (*model.PipelineDefinition, error)
PublishDefinition(ctx context.Context, name string, version int) (*model.PipelineDefinition, error)
EnsureDefinitionCreatedBy(ctx context.Context, name, createdBy string) error
DeleteDefinitionByName(ctx context.Context, name string) (int64, error)
ListPublishedDefinitions(ctx context.Context) ([]DefinitionRecord, error)
GetRunsByParentName(ctx context.Context, parentName string) ([]*model.PipelineRun, error)
}
DefinitionCatalog loads and mutates pipeline definitions stored in the database.
type DefinitionReader ¶
type DefinitionReader interface {
ListPublishedDefinitions(ctx context.Context) ([]DefinitionRecord, error)
}
DefinitionReader is the interface for loading published definitions from a store.
type DefinitionRecord ¶
type DefinitionRecord struct {
Name string
Description string
YAML string
// CreatedBy is the Web UI user UID that created the pipeline.
CreatedBy string
UpdatedAt time.Time
}
DefinitionRecord holds a published pipeline definition loaded from the database.
type DefinitionSource ¶ added in v0.95.0
type DefinitionSource func(ctx context.Context) ([]Definition, error)
DefinitionSource loads the current pipeline definitions for engine reload.
type EditorDefinition ¶
type EditorDefinition struct {
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
Enabled bool `json:"enabled" yaml:"enabled"`
Resumable bool `json:"resumable" yaml:"resumable"`
Triggers []TriggerEntry `json:"triggers" yaml:"triggers"`
Steps []Step `json:"steps" yaml:"steps"`
}
EditorDefinition is the YAML schema used by the pipeline editor UI. It supports multiple triggers (array) unlike the engine's Definition (single Trigger).
func ParseEditorYAML ¶
func ParseEditorYAML(yamlStr string) (*EditorDefinition, error)
ParseEditorYAML parses a YAML string into an EditorDefinition.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func ActiveEngine ¶ added in v0.99.0
func ActiveEngine() *Engine
ActiveEngine returns the wired Engine, or nil if not set.
func NewEngine ¶
func NewEngine(defs []Definition, store RunStore, auditor audit.Auditor, pc *metrics.PipelineCollector, ec *metrics.EventCollector) *Engine
func NewEngineWithClock ¶
func NewEngineWithClock(defs []Definition, store RunStore, auditor audit.Auditor, pc *metrics.PipelineCollector, ec *metrics.EventCollector, clock Clock) *Engine
func (*Engine) ExecuteManual ¶ added in v0.99.0
func (e *Engine) ExecuteManual(ctx context.Context, parentName string, event types.DataEvent) (int64, error)
ExecuteManual starts a manual pipeline run and returns the run ID immediately. Steps continue in a detached goroutine. event.EventID must be non-empty and unique.
func (*Engine) ExecuteWebhook ¶
ExecuteWebhook executes a pipeline from a webhook trigger. Concurrent webhook/event runs for the same pipeline are allowed; cron overlap control uses a separate TryLock path in executeCronJob.
func (*Engine) LookupWebhook ¶ added in v0.98.2
func (e *Engine) LookupWebhook(path string) (*Definition, bool)
LookupWebhook returns the pipeline definition for a webhook path (without the /webhook/ prefix). Paths are matched with leading slashes trimmed. The returned pointer is only valid until the next Reload.
func (*Engine) MutexFor ¶
MutexFor returns the per-pipeline mutex used to skip overlapping cron ticks. Event and webhook execution do not hold this mutex for the run duration. Exported for testing (BDD specs).
func (*Engine) RegisterWebhooks ¶
func (e *Engine) RegisterWebhooks() (map[string]*Definition, error)
RegisterWebhooks returns a map of webhook path to pipeline Definition for all webhook-enabled pipelines. Duplicate paths return an error.
func (*Engine) Reload ¶ added in v0.95.0
func (e *Engine) Reload(defs []Definition) error
Reload replaces in-memory pipeline definitions and refreshes cron registrations. Event handlers and the catch-all webhook route look up defs dynamically after reload.
func (*Engine) ResumePipeline ¶
ResumePipeline attempts to resume a pipeline run from its last checkpoint. It reloads the checkpoint, reconstructs the RenderContext, and continues from the checkpointed step index.
func (*Engine) RetryFailedRun ¶ added in v0.99.8
RetryFailedRun reclaims a failed run and continues from the first failed step using the current published definition. Successful steps are not re-invoked. Remaining steps run in a detached goroutine; the same run ID is kept.
func (*Engine) SetCallback ¶
func (e *Engine) SetCallback(cb StepCallback)
SetCallback sets the progress event callback. Pass nil to disable.
type FakeClock ¶
type FakeClock struct {
// contains filtered or unexported fields
}
FakeClock provides deterministic time for tests. All timer channels fire in order when Advance is called.
func NewFakeClock ¶
NewFakeClock returns a new FakeClock seeded at the given time.
func (*FakeClock) Advance ¶
Advance moves the clock forward by d and fires all timers whose deadlines are at or before the new time, in chronological order.
type InstantiateRequest ¶
type InstantiateRequest struct {
Source string
BlueprintID string
PipelineName string
Inputs map[string]any
Enable bool
CreatedBy string
}
InstantiateRequest creates a linked pipeline from a catalog template.
type ListInfo ¶ added in v0.99.0
type ListInfo struct {
Name string `json:"name"`
Description string `json:"description"`
Enabled bool `json:"enabled"`
Resumable bool `json:"resumable"`
Triggers []string `json:"triggers"`
}
ListInfo is a published pipeline summary for list APIs.
type RealClock ¶
type RealClock struct{}
RealClock delegates to the system clock.
type RenderContext ¶
type RenderContext struct {
Event types.DataEvent
Steps map[string]map[string]any
Input map[string]any
// contains filtered or unexported fields
}
func NewRenderContext ¶
func NewRenderContext(event types.DataEvent) *RenderContext
func (*RenderContext) RecordStepResult ¶
func (rc *RenderContext) RecordStepResult(stepName string, result map[string]any)
func (*RenderContext) RenderParams ¶
func (*RenderContext) RenderString ¶
func (rc *RenderContext) RenderString(s string) (string, error)
type RunStore ¶
type RunStore interface {
CreateRun(ctx context.Context, pipelineName, eventID, eventType, triggerSource string) (*model.PipelineRun, error)
UpdateRunStatus(ctx context.Context, runID int64, status int, errMsg string) error
CreateStepRun(ctx context.Context, runID int64, stepName, capName, operation string, params map[string]any, attempt int) (*model.PipelineStepRun, error)
UpdateStepRun(ctx context.Context, stepRunID int64, status int, result map[string]any, errMsg string, attempt int) error
ListStepRuns(ctx context.Context, runID int64) ([]*model.PipelineStepRun, error)
ClaimFailedRun(ctx context.Context, runID int64) error
PrepareStepRetry(ctx context.Context, stepRunID int64, params map[string]any, attempt int) error
SaveCheckpoint(ctx context.Context, runID int64, data any) error
GetIncompleteRuns(ctx context.Context) ([]*model.PipelineRun, error)
GetCheckpoint(ctx context.Context, runID int64, target any) error
GetRun(ctx context.Context, runID int64) (*model.PipelineRun, error)
UpdateRunHeartbeat(ctx context.Context, runID int64) error
HasConsumed(ctx context.Context, consumerName, eventID string) (bool, error)
RecordConsumption(ctx context.Context, consumerName, eventID string) error
RecordResourceLink(ctx context.Context, link model.ResourceLink) error
}
RunStore abstracts persistence for pipeline runs, steps, checkpoints and event consumption.
type Service ¶ added in v0.99.0
type Service struct {
// contains filtered or unexported fields
}
Service orchestrates DB-backed pipeline apply/run and engine reload.
func ActiveService ¶ added in v0.99.0
func ActiveService() *Service
ActiveService returns the wired Service, or nil if not set.
func NewService ¶ added in v0.99.0
func NewService(catalog DefinitionCatalog) *Service
NewService creates a pipeline definition Service.
func (*Service) ApplyYAML ¶ added in v0.99.0
func (s *Service) ApplyYAML(ctx context.Context, data []byte, createdBy string) (*ApplyResult, error)
ApplyYAML parses YAML, writes draft, publishes immediately, and reloads the engine.
func (*Service) Delete ¶ added in v0.99.0
Delete removes a pipeline definition (and parent/compound runs) and reloads the engine.
type StepCallback ¶
type StepCallback interface {
OnRunStart(ctx context.Context, runID int64, pipelineName string,
trigger string, totalSteps int, stepNames []string)
OnStepStart(ctx context.Context, runID int64, pipelineName string,
stepIndex int, stepName string, input map[string]any)
OnStepDone(ctx context.Context, runID int64, pipelineName string,
stepIndex int, stepName string, output map[string]any, elapsedMs int64)
OnStepError(ctx context.Context, runID int64, pipelineName string,
stepIndex int, stepName string, err error, elapsedMs int64)
OnRunComplete(ctx context.Context, runID int64, pipelineName string,
elapsedMs int64, failed bool, errMsg string)
}
StepCallback receives progress events during pipeline execution. All methods are called synchronously from the step execution loop. nil receiver is safe — Engine skips calls when callback is nil.
type StepProgressEvent ¶
type StepProgressEvent struct {
RunID int64 `json:"run_id"`
PipelineName string `json:"pipeline_name"`
StepIndex int `json:"step_index"`
StepName string `json:"step_name"`
Status string `json:"status"`
Input map[string]any `json:"input,omitempty"`
Output map[string]any `json:"output,omitempty"`
ElapsedMs int64 `json:"elapsed_ms,omitempty"`
Error string `json:"error,omitempty"`
TotalSteps int `json:"total_steps,omitempty"`
}
StepProgressEvent is the JSON payload for a single progress update. StepIndex of -1 indicates a run-level event (start/complete/failed).
type StepResult ¶
type StepResult struct {
Name string `json:"name"`
Capability string `json:"capability"`
Operation string `json:"operation"`
Output map[string]any `json:"output"`
CompletedAt time.Time `json:"completed_at"`
}
StepResult captures the output of a completed pipeline step.
type Trigger ¶
type Trigger struct {
Event string
Cron string
CronTimeout time.Duration
Webhook *WebhookConfig
}
type TriggerEntry ¶
type TriggerEntry struct {
Enabled bool `json:"enabled" yaml:"enabled"`
Type string `json:"type" yaml:"type"` // "event", "cron", "webhook"
Event string `json:"event,omitempty" yaml:"event,omitempty"`
Cron string `json:"cron,omitempty" yaml:"cron,omitempty"`
CronTimeout string `json:"cron_timeout,omitempty" yaml:"cron_timeout,omitempty"`
Webhook *WebhookConfig `json:"webhook,omitempty" yaml:"webhook,omitempty"`
}
TriggerEntry represents a single trigger in the editor's triggers array.
type WebhookAuthConfig ¶
type WebhookConfig ¶
type WebhookConfig struct {
Path string
Method string
Auth WebhookAuthConfig
Payload config.WebhookPayloadMode
EventType string
}