Documentation
¶
Index ¶
- Constants
- Variables
- func CanTransition(from, to Status) bool
- func IsTerminal(status Status) bool
- type AsyncResultStore
- type AsyncTask
- type AsyncTaskState
- type AsyncTaskStore
- type EventType
- type GormStore
- func (s *GormStore) AcknowledgeAsyncTask(ctx context.Context, dispatchID, claimToken string) error
- func (s *GormStore) AppendEvent(ctx context.Context, event RunEvent) error
- func (s *GormStore) CancelAsyncTasks(ctx context.Context, runID string) error
- func (s *GormStore) ClaimCompletedAsyncTasks(ctx context.Context, now time.Time, limit int, lease time.Duration) ([]*AsyncTask, error)
- func (s *GormStore) CommitAsyncResult(ctx context.Context, task *AsyncTask, run *WorkflowRun, ...) error
- func (s *GormStore) Events(ctx context.Context, runID string) ([]RunEvent, error)
- func (s *GormStore) FailInterruptedRuns(ctx context.Context) (int, error)
- func (s *GormStore) ListRuns(ctx context.Context) ([]*WorkflowRun, error)
- func (s *GormStore) LoadRun(ctx context.Context, runID string) (*WorkflowRun, error)
- func (s *GormStore) ReleaseAsyncTask(ctx context.Context, dispatchID, claimToken string) error
- func (s *GormStore) RenewAsyncTask(ctx context.Context, dispatchID, claimToken string, claimUntil time.Time) (bool, error)
- func (s *GormStore) SaveAsyncTask(ctx context.Context, task *AsyncTask) error
- func (s *GormStore) SaveRun(ctx context.Context, run *WorkflowRun) error
- func (s *GormStore) SaveSnapshot(ctx context.Context, snapshot *RunSnapshot) error
- func (s *GormStore) Snapshots(ctx context.Context, runID string) ([]*RunSnapshot, error)
- func (s *GormStore) SubmitAsyncResult(ctx context.Context, dispatchID string, result executor.ExecuteResult) (bool, error)
- type MemoryStore
- func (s *MemoryStore) AcknowledgeAsyncTask(ctx context.Context, dispatchID, claimToken string) error
- func (s *MemoryStore) AppendEvent(_ context.Context, event RunEvent) error
- func (s *MemoryStore) CancelAsyncTasks(_ context.Context, runID string) error
- func (s *MemoryStore) ClaimCompletedAsyncTasks(_ context.Context, now time.Time, limit int, lease time.Duration) ([]*AsyncTask, error)
- func (s *MemoryStore) CommitAsyncResult(ctx context.Context, task *AsyncTask, run *WorkflowRun, ...) error
- func (s *MemoryStore) Events(_ context.Context, runID string) ([]RunEvent, error)
- func (s *MemoryStore) ListRuns(_ context.Context) ([]*WorkflowRun, error)
- func (s *MemoryStore) LoadRun(_ context.Context, runID string) (*WorkflowRun, error)
- func (s *MemoryStore) ReleaseAsyncTask(ctx context.Context, dispatchID, claimToken string) error
- func (s *MemoryStore) RenewAsyncTask(_ context.Context, dispatchID, claimToken string, claimUntil time.Time) (bool, error)
- func (s *MemoryStore) SaveAsyncTask(_ context.Context, task *AsyncTask) error
- func (s *MemoryStore) SaveRun(_ context.Context, run *WorkflowRun) error
- func (s *MemoryStore) SaveSnapshot(_ context.Context, snapshot *RunSnapshot) error
- func (s *MemoryStore) Snapshots(_ context.Context, runID string) ([]*RunSnapshot, error)
- func (s *MemoryStore) SubmitAsyncResult(_ context.Context, dispatchID string, result executor.ExecuteResult) (bool, error)
- type NodeRun
- type RunContext
- type RunEvent
- type RunSnapshot
- type Status
- type Store
- type WorkflowRun
Constants ¶
View Source
const InterruptedRunMessage = "server restarted before the run completed"
Variables ¶
View Source
var ( ErrAsyncTaskNotFound = errors.New("async task not found") ErrAsyncTaskCancelled = errors.New("async task is cancelled") ErrAsyncResultConflict = errors.New("async task already has a different result") ErrAsyncClaimLost = errors.New("async task claim is no longer valid") ErrAsyncRunChanged = errors.New("async task run has changed") ErrAsyncTaskExpired = errors.New("async callback timeout") )
View Source
var ErrRunNotFound = errors.New("run not found")
Functions ¶
func CanTransition ¶
func IsTerminal ¶
Types ¶
type AsyncResultStore ¶ added in v1.2.20
type AsyncResultStore interface {
CommitAsyncResult(ctx context.Context, task *AsyncTask, run *WorkflowRun, expectedUpdatedAt time.Time, snapshots []*RunSnapshot, events []RunEvent) error
}
AsyncResultStore atomically commits callback effects and their application marker under a live task/run claim. Implementations must reject stale claims, changed runs and cancelled tasks, without persisting any partial effects. The marker survives claim release so retries and loops cannot apply a callback twice even when its node is pending again or has a newer dispatch ID.
type AsyncTask ¶ added in v1.2.20
type AsyncTask struct {
DispatchID string `json:"dispatch_id"`
RunID string `json:"run_id"`
NodeID string `json:"node_id"`
ExternalTaskID string `json:"external_task_id"`
Task executor.ExecuteTask `json:"task"`
Result *executor.ExecuteResult `json:"result,omitempty"`
ResultHash string `json:"-"`
ResultApplied bool `json:"-"`
// ExpireAt is the persisted callback deadline; zero means no expiration.
ExpireAt time.Time `json:"expire_at,omitempty,omitzero"`
State AsyncTaskState `json:"state"`
ClaimToken string `json:"-"`
ClaimUntil time.Time `json:"-"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type AsyncTaskState ¶ added in v1.2.20
type AsyncTaskState string
const ( AsyncTaskWaiting AsyncTaskState = "waiting" AsyncTaskCompleted AsyncTaskState = "completed" AsyncTaskClaimed AsyncTaskState = "claimed" AsyncTaskDone AsyncTaskState = "done" AsyncTaskCancelled AsyncTaskState = "cancelled" )
type AsyncTaskStore ¶ added in v1.2.20
type AsyncTaskStore interface {
SaveAsyncTask(ctx context.Context, task *AsyncTask) error
SubmitAsyncResult(ctx context.Context, dispatchID string, result executor.ExecuteResult) (bool, error)
// ClaimCompletedAsyncTasks also atomically completes expired waiting tasks
// with a non-retryable timeout result before claiming recovery work.
ClaimCompletedAsyncTasks(ctx context.Context, now time.Time, limit int, lease time.Duration) ([]*AsyncTask, error)
RenewAsyncTask(ctx context.Context, dispatchID, claimToken string, claimUntil time.Time) (bool, error)
AcknowledgeAsyncTask(ctx context.Context, dispatchID, claimToken string) error
ReleaseAsyncTask(ctx context.Context, dispatchID, claimToken string) error
CancelAsyncTasks(ctx context.Context, runID string) error
}
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" EventNodeWaiting EventType = "node_waiting" 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 NewGormStoreWithTablePrefix ¶ added in v1.2.13
func (*GormStore) AcknowledgeAsyncTask ¶ added in v1.2.20
func (*GormStore) AppendEvent ¶
func (*GormStore) CancelAsyncTasks ¶ added in v1.2.20
func (*GormStore) ClaimCompletedAsyncTasks ¶ added in v1.2.20
func (*GormStore) CommitAsyncResult ¶ added in v1.2.20
func (s *GormStore) CommitAsyncResult(ctx context.Context, task *AsyncTask, run *WorkflowRun, expectedUpdatedAt time.Time, snapshots []*RunSnapshot, events []RunEvent) error
func (*GormStore) FailInterruptedRuns ¶
func (*GormStore) ListRuns ¶
func (s *GormStore) ListRuns(ctx context.Context) ([]*WorkflowRun, error)
func (*GormStore) ReleaseAsyncTask ¶ added in v1.2.20
func (*GormStore) RenewAsyncTask ¶ added in v1.2.20
func (*GormStore) SaveAsyncTask ¶ added in v1.2.20
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) SubmitAsyncResult ¶ added in v1.2.20
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
func (*MemoryStore) AcknowledgeAsyncTask ¶ added in v1.2.20
func (s *MemoryStore) AcknowledgeAsyncTask(ctx context.Context, dispatchID, claimToken string) error
func (*MemoryStore) AppendEvent ¶
func (s *MemoryStore) AppendEvent(_ context.Context, event RunEvent) error
func (*MemoryStore) CancelAsyncTasks ¶ added in v1.2.20
func (s *MemoryStore) CancelAsyncTasks(_ context.Context, runID string) error
func (*MemoryStore) ClaimCompletedAsyncTasks ¶ added in v1.2.20
func (*MemoryStore) CommitAsyncResult ¶ added in v1.2.20
func (s *MemoryStore) CommitAsyncResult(ctx context.Context, task *AsyncTask, run *WorkflowRun, expectedUpdatedAt time.Time, snapshots []*RunSnapshot, events []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) ReleaseAsyncTask ¶ added in v1.2.20
func (s *MemoryStore) ReleaseAsyncTask(ctx context.Context, dispatchID, claimToken string) error
func (*MemoryStore) RenewAsyncTask ¶ added in v1.2.20
func (*MemoryStore) SaveAsyncTask ¶ added in v1.2.20
func (s *MemoryStore) SaveAsyncTask(_ context.Context, task *AsyncTask) 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)
func (*MemoryStore) SubmitAsyncResult ¶ added in v1.2.20
func (s *MemoryStore) SubmitAsyncResult(_ context.Context, dispatchID string, result executor.ExecuteResult) (bool, error)
type NodeRun ¶
type NodeRun struct {
NodeID string `json:"node_id"`
DispatchID string `json:"dispatch_id,omitempty"`
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 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 Status ¶
type Status string
const ( StatusPending Status = "pending" StatusRunning Status = "running" StatusWaiting Status = "waiting" 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
Click to show internal directories.
Click to hide internal directories.