Documentation
¶
Overview ¶
Package run implements storage for workflow runs.
Index ¶
- Constants
- func MarshalRun(w *WorkflowRun) ([]byte, error)
- type Store
- func (s *Store) Close() error
- func (s *Store) ListRuns(workflow, status string, limit, offset int) ([]*WorkflowRun, error)
- func (s *Store) Load(id string) (*WorkflowRun, error)
- func (s *Store) LoadTaskRuns(runID string) ([]TaskRun, error)
- func (s *Store) NewWorkflowRun(workflow string, dagHash string) (*WorkflowRun, error)
- func (s *Store) SaveTaskRun(task *TaskRun) error
- func (s *Store) Update(run *WorkflowRun) error
- func (s *Store) UpdateTaskRun(task *TaskRun) error
- type TaskPlan
- type TaskRun
- type TaskStatus
- type WorkflowPlan
- type WorkflowRun
- type WorkflowStatus
Constants ¶
const ( QueryCreateWorkflowRun = `` /* 135-byte string literal not displayed */ QueryUpdateWorkflowRun = ` UPDATE workflow_runs SET status = ?, ended_at = ?, exit_code = ?, meta = ? WHERE id = ? ` QueryLoadWorkflowRun = `` /* 155-byte string literal not displayed */ QueryListRuns = `` /* 228-byte string literal not displayed */ QueryCreateTaskRun = `` /* 166-byte string literal not displayed */ QueryUpdateTaskRun = `` /* 147-byte string literal not displayed */ QueryLoadTaskRuns = `` /* 158-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func MarshalRun ¶
func MarshalRun(w *WorkflowRun) ([]byte, error)
MarshalRun converts a WorkflowRun to JSON bytes.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages the persistence of WorkflowRun instances using SQLite.
func (*Store) ListRuns ¶
func (s *Store) ListRuns(workflow, status string, limit, offset int) ([]*WorkflowRun, error)
ListRuns retrieves workflow runs with optional filtering and pagination.
func (*Store) Load ¶
func (s *Store) Load(id string) (*WorkflowRun, error)
Load retrieves a WorkflowRun by its ID.
func (*Store) LoadTaskRuns ¶
LoadTaskRuns retrieves all TaskRuns for a given WorkflowRun.
func (*Store) NewWorkflowRun ¶
func (s *Store) NewWorkflowRun(workflow string, dagHash string) (*WorkflowRun, error)
NewWorkflowRun creates and stores a new WorkflowRun with the given workflow name and DAG hash.
func (*Store) SaveTaskRun ¶
SaveTaskRun persists a TaskRun to the database.
func (*Store) Update ¶
func (s *Store) Update(run *WorkflowRun) error
Update persists changes to an existing WorkflowRun.
func (*Store) UpdateTaskRun ¶
UpdateTaskRun updates an existing TaskRun.
type TaskPlan ¶
type TaskPlan struct {
Order int `json:"order"`
Name string `json:"name"`
Cmd string `json:"cmd"`
DependsOn []string `json:"depends_on"`
Retries int `json:"retries"`
}
TaskPlan represents the plan for a single task in a workflow.
type TaskRun ¶
type TaskRun struct {
ID int64 `db:"id"`
RunID string `db:"run_id"` // Foreign key to WorkflowRun
Name string `db:"name"`
Status TaskStatus `db:"status"`
StartedAt time.Time `db:"started_at"`
EndedAt sql.NullTime `db:"ended_at"`
Attempts int `db:"attempts"`
ExitCode sql.NullInt64 `db:"exit_code"`
LogPath string `db:"log_path"`
LastError string `db:"last_error"`
}
TaskRun represents the execution details of a single task within a workflow.
type TaskStatus ¶
type TaskStatus string
const ( TaskPending TaskStatus = "pending" TaskRunning TaskStatus = "running" TaskSuccess TaskStatus = "success" TaskFailed TaskStatus = "failed" )
type WorkflowPlan ¶
WorkflowPlan represents the plan for a workflow.
type WorkflowRun ¶
type WorkflowRun struct {
ID string `db:"id"`
Workflow string `db:"workflow"`
WorkflowHash string `db:"workflow_hash"`
Status WorkflowStatus `db:"status"`
StartedAt time.Time `db:"started_at"`
EndedAt sql.NullTime `db:"ended_at"`
ExitCode sql.NullInt64 `db:"exit_code"`
Meta sql.NullString `db:"meta"` // JSON string
CreatedAt time.Time `db:"created_at"`
}
WorkflowRun represents a single execution of a workflow.
func (*WorkflowRun) MarshalMeta ¶
func (w *WorkflowRun) MarshalMeta(meta map[string]interface{}) error
MarshalMeta converts Meta map to JSON string for storage
func (*WorkflowRun) UnmarshalMeta ¶
func (w *WorkflowRun) UnmarshalMeta() (map[string]interface{}, error)
UnmarshalMeta converts JSON string back to Meta map
type WorkflowStatus ¶
type WorkflowStatus string
const ( StatusPending WorkflowStatus = "pending" StatusRunning WorkflowStatus = "running" StatusSuccess WorkflowStatus = "success" StatusFailed WorkflowStatus = "failed" )