run

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package run implements storage for workflow runs.

Index

Constants

View Source
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 NewStore

func NewStore(dbPath string) (*Store, error)

NewStore initialises a new Store with SQLite database at the given path.

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection.

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

func (s *Store) LoadTaskRuns(runID string) ([]TaskRun, error)

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

func (s *Store) SaveTaskRun(task *TaskRun) error

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

func (s *Store) UpdateTaskRun(task *TaskRun) error

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

type WorkflowPlan struct {
	Workflow string     `json:"workflow"`
	Tasks    []TaskPlan `json:"tasks"`
}

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"
)

Jump to

Keyboard shortcuts

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