wfruntime

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const InterruptedRunMessage = "server restarted before the run completed"

Variables

View Source
var ErrRunNotFound = errors.New("run not found")

Functions

func CanTransition

func CanTransition(from, to Status) bool

func IsTerminal

func IsTerminal(status Status) bool

Types

type EventType

type EventType string
const (
	EventRunStarted  EventType = "run_started"
	EventRunFinished EventType = "run_finished"
	EventRunPaused   EventType = "run_paused"
	EventRunResumed  EventType = "run_resumed"
	EventNodeReady   EventType = "node_ready"
	EventNodeRunning EventType = "node_running"
	EventNodeLoop    EventType = "node_loop"
	EventNodeRetry   EventType = "node_retry"
	EventNodeDone    EventType = "node_done"
	EventNodeFailed  EventType = "node_failed"
)

type GormStore

type GormStore struct {
	// contains filtered or unexported fields
}

func NewGormStore deprecated

func NewGormStore(db *gorm.DB) (*GormStore, error)

NewGormStore constructs the legacy standalone runtime adapter.

Deprecated: new applications should compose the complete adapter through persist/gormstore.New. This constructor remains available for compatibility.

func (*GormStore) AppendEvent

func (s *GormStore) AppendEvent(ctx context.Context, event RunEvent) error

func (*GormStore) Events

func (s *GormStore) Events(ctx context.Context, runID string) ([]RunEvent, error)

func (*GormStore) FailInterruptedRuns

func (s *GormStore) FailInterruptedRuns(ctx context.Context) (int, error)

func (*GormStore) ListRuns

func (s *GormStore) ListRuns(ctx context.Context) ([]*WorkflowRun, error)

func (*GormStore) LoadRun

func (s *GormStore) LoadRun(ctx context.Context, runID string) (*WorkflowRun, error)

func (*GormStore) SaveRun

func (s *GormStore) SaveRun(ctx context.Context, run *WorkflowRun) error

func (*GormStore) SaveSnapshot

func (s *GormStore) SaveSnapshot(ctx context.Context, snapshot *RunSnapshot) error

func (*GormStore) Snapshots

func (s *GormStore) Snapshots(ctx context.Context, runID string) ([]*RunSnapshot, error)

type MemoryStore

type MemoryStore struct {
	// contains filtered or unexported fields
}

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) AppendEvent

func (s *MemoryStore) AppendEvent(_ context.Context, event RunEvent) error

func (*MemoryStore) Events

func (s *MemoryStore) Events(_ context.Context, runID string) ([]RunEvent, error)

func (*MemoryStore) ListRuns

func (s *MemoryStore) ListRuns(_ context.Context) ([]*WorkflowRun, error)

func (*MemoryStore) LoadRun

func (s *MemoryStore) LoadRun(_ context.Context, runID string) (*WorkflowRun, error)

func (*MemoryStore) SaveRun

func (s *MemoryStore) SaveRun(_ context.Context, run *WorkflowRun) error

func (*MemoryStore) SaveSnapshot

func (s *MemoryStore) SaveSnapshot(_ context.Context, snapshot *RunSnapshot) error

func (*MemoryStore) Snapshots

func (s *MemoryStore) Snapshots(_ context.Context, runID string) ([]*RunSnapshot, error)

type NodeRun

type NodeRun struct {
	NodeID      string    `json:"node_id"`
	Status      Status    `json:"status"`
	Attempt     int       `json:"attempt"`
	MaxAttempts int       `json:"max_attempts,omitempty"`
	StartedAt   time.Time `json:"started_at,omitempty"`
	FinishedAt  time.Time `json:"finished_at,omitempty"`
	// Input keeps the latest materialized task input so the UI can explain what
	// a node actually received during execution instead of only showing config.
	Input    any            `json:"input,omitempty"`
	Result   any            `json:"result,omitempty"`
	Error    string         `json:"error,omitempty"`
	Metadata map[string]any `json:"metadata,omitempty"`
}

type RunContext

type RunContext struct {
	Variables   map[string]any `json:"variables,omitempty"`
	NodeResults map[string]any `json:"node_results,omitempty"`
}

type RunEvent

type RunEvent struct {
	RunID      string         `json:"run_id"`
	Type       EventType      `json:"type"`
	NodeID     string         `json:"node_id,omitempty"`
	Status     Status         `json:"status,omitempty"`
	Time       time.Time      `json:"time"`
	Message    string         `json:"message,omitempty"`
	Payload    map[string]any `json:"payload,omitempty"`
	WorkflowID string         `json:"workflow_id,omitempty"`
}

type RunSnapshot

type RunSnapshot struct {
	RunID       string              `json:"run_id"`
	Status      Status              `json:"status"`
	NodeRuns    map[string]*NodeRun `json:"node_runs"`
	Context     RunContext          `json:"context"`
	At          time.Time           `json:"at"`
	Description string              `json:"description,omitempty"`
}

type Status

type Status string
const (
	StatusPending   Status = "pending"
	StatusRunning   Status = "running"
	StatusSuccess   Status = "success"
	StatusFailed    Status = "failed"
	StatusRetry     Status = "retry"
	StatusPaused    Status = "paused"
	StatusCancelled Status = "cancelled"
	StatusTimeout   Status = "timeout"
)

type Store

type Store interface {
	SaveRun(ctx context.Context, run *WorkflowRun) error
	LoadRun(ctx context.Context, runID string) (*WorkflowRun, error)
	ListRuns(ctx context.Context) ([]*WorkflowRun, error)
	SaveSnapshot(ctx context.Context, snapshot *RunSnapshot) error
	Snapshots(ctx context.Context, runID string) ([]*RunSnapshot, error)
	AppendEvent(ctx context.Context, event RunEvent) error
	Events(ctx context.Context, runID string) ([]RunEvent, error)
}

type WorkflowRun

type WorkflowRun struct {
	ID                 string              `json:"id"`
	WorkflowID         string              `json:"workflow_id"`
	WorkflowVersionID  string              `json:"workflow_version_id"`
	PlanID             string              `json:"plan_id"`
	RequestFingerprint string              `json:"request_fingerprint,omitempty"`
	CredentialScope    string              `json:"credential_scope,omitempty"`
	Status             Status              `json:"status"`
	CurrentNodes       []string            `json:"current_nodes,omitempty"`
	NodeRuns           map[string]*NodeRun `json:"node_runs,omitempty"`
	Context            RunContext          `json:"context"`
	CreatedAt          time.Time           `json:"created_at"`
	UpdatedAt          time.Time           `json:"updated_at"`
	StartedAt          time.Time           `json:"started_at,omitempty"`
	FinishedAt         time.Time           `json:"finished_at,omitempty"`
	// contains filtered or unexported fields
}

func NewWorkflowRun

func NewWorkflowRun(runID, workflowID, versionID, planID string) *WorkflowRun

func (*WorkflowRun) Clone

func (r *WorkflowRun) Clone() *WorkflowRun

Jump to

Keyboard shortcuts

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