models

package
v2.0.21 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActionColumnsSet = sets.New(
	"project",
	"domain",
	"run_name",
	"phase",
	"run_source",
	"trigger_task_name",
	"trigger_name",
	"trigger_revision",
	"trigger_type",
	"task_project",
	"task_domain",
	"task_name",
	"task_version",
	"function_name",
	"created_at",
	"updated_at",
	"ended_at",
	"duration_ms",
)

ActionColumnsSet is the allowlist of columns that can be used in filters/sort for the actions table. This prevents SQL injection via user-supplied field names.

View Source
var (
	Marshaller = proto.MarshalOptions{}
)
View Source
var ProjectColumns = sets.New[string](
	"identifier",
	"name",
	"description",
	"labels",
	"state",
	"created_at",
	"updated_at",
)
View Source
var TaskColumns = sets.New(
	"project",
	"domain",
	"name",
	"version",
	"environment",
	"function_name",
	"deployed_by",
	"created_at",
	"updated_at",
	"trigger_name",
	"total_triggers",
	"active_triggers",
	"env_description",
	"short_description",
)

TaskColumns are the allowed columns for task queries

View Source
var TaskVersionColumns = sets.New(
	"version",
	"created_at",
)

TaskVersionColumns are the allowed columns for task version queries

View Source
var TriggerColumns = sets.New(
	"project", "domain", "task_name", "name",
	"active", "deployed_at", "updated_at",
	"task_version", "automation_type",
)

TriggerColumns are the allowed columns for trigger list/sort queries.

View Source
var TriggerRevisionColumns = sets.New(
	"revision", "deployed_at", "updated_at", "action",
)

TriggerRevisionColumns are the allowed columns for trigger revision list/sort queries.

Functions

This section is empty.

Types

type Action

type Action struct {
	// Action Identifier (unique across project/domain/run_name/name)
	Project string `db:"project"`
	Domain  string `db:"domain"`
	RunName string `db:"run_name"`
	Name    string `db:"name"`

	// Parent action (NULL for root actions/runs)
	ParentActionName sql.NullString `db:"parent_action_name"`

	// High-level status for quick queries/filtering.
	// Stores the proto ActionPhase enum integer value directly (e.g. 1 = QUEUED).
	Phase int32 `db:"phase"`

	// Who initiated this run(web, CLI, scheduler, etc.)
	RunSource string `db:"run_source" json:"run_source,omitempty"`

	// Trigger fields — only set for runs created via RUN_SOURCE_SCHEDULE_TRIGGER.
	TriggerTaskName sql.NullString `db:"trigger_task_name"`
	TriggerName     sql.NullString `db:"trigger_name"`
	TriggerRevision sql.NullInt64  `db:"trigger_revision"`
	// TriggerType stores the automation type string (e.g. "TYPE_SCHEDULE").
	TriggerType sql.NullString `db:"trigger_type"`

	// Action type (task, trace, condition). Stores workflow.ActionType enum value.
	ActionType int32 `db:"action_type"`
	// Group this action belongs to, if applicable.
	ActionGroup sql.NullString `db:"action_group"`

	// Task reference columns
	TaskProject sql.NullString `db:"task_project"`
	TaskDomain  sql.NullString `db:"task_domain"`
	TaskName    sql.NullString `db:"task_name"`
	TaskVersion sql.NullString `db:"task_version"`

	// Task metadata columns
	TaskType        string         `db:"task_type"`
	TaskShortName   sql.NullString `db:"task_short_name"`
	FunctionName    string         `db:"function_name"`
	EnvironmentName sql.NullString `db:"environment_name"`

	// Serialized protobuf messages
	// ActionSpec contains the full action specification proto
	ActionSpec []byte `db:"action_spec"`

	// ActionDetails contains the full action details proto:
	// - ActionStatus (phase, timestamps, error, cache status, etc.)
	// - ActionAttempts array (all attempts with their phase transitions, cluster events, logs, etc.)
	// - Any other runtime state
	ActionDetails []byte `db:"action_details"`

	// DetailedInfo stores a serialized RunInfo proto containing metadata such as
	// the task spec digest (for looking up the resolved spec) and storage URIs.
	DetailedInfo []byte `db:"detailed_info"`

	// RunSpec stores a serialized task.RunSpec proto (labels, annotations, envs,
	// interruptible, cluster, etc.) for this action's run.
	RunSpec []byte `db:"run_spec"`

	// Abort tracking — set when a user requests abort; cleared once the pod is confirmed terminated.
	AbortRequestedAt  *time.Time `db:"abort_requested_at"`
	AbortAttemptCount int        `db:"abort_attempt_count"`
	AbortReason       *string    `db:"abort_reason"`

	// Timestamps
	// CreatedAt is set by the DB (NOW()) on insert — represents when the action was queued.
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
	// EndedAt is set when the action reaches a terminal phase.
	EndedAt     sql.NullTime            `db:"ended_at"`
	DurationMs  sql.NullInt64           `db:"duration_ms"`
	Attempts    uint32                  `db:"attempts" json:"attempts,omitempty"`
	CacheStatus core.CatalogCacheStatus `db:"cache_status" json:"cache_status,omitempty"`
}

Action represents a workflow action in the database Root actions (where ParentActionName is NULL) represent runs

func NewActionModel added in v2.0.12

func NewActionModel(actionID *common.ActionIdentifier) *Action

func (*Action) Clone added in v2.0.8

func (a *Action) Clone() *Action

Clone returns an independent copy of the action, including pointer and JSON fields.

func (*Action) GetRunName

func (a *Action) GetRunName() string

GetRunName extracts the run name from the action For root actions (runs), returns the action's own name For child actions, extracts from ActionSpec JSON

type ActionEvent added in v2.0.8

type ActionEvent struct {
	// Composite primary key
	Project string `db:"project"`
	Domain  string `db:"domain"`
	RunName string `db:"run_name"`
	Name    string `db:"name"`
	Attempt uint32 `db:"attempt"`
	Phase   int32  `db:"phase"` // common.ActionPhase
	Version uint32 `db:"version"`

	// Serialized workflow.ActionEvent proto
	Info []byte `db:"info"`

	// Error kind denormalized from Info for faster queries
	ErrorKind *string `db:"error_kind"`

	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

ActionEvent represents a single phase transition event for an action attempt. Composite PK: (project, domain, run_name, name, attempt, phase, version).

func NewActionEventModel added in v2.0.8

func NewActionEventModel(event *workflow.ActionEvent) (*ActionEvent, error)

NewActionEventModel builds an ActionEvent model from a proto ActionEvent.

func (*ActionEvent) ToActionEvent added in v2.0.9

func (m *ActionEvent) ToActionEvent() (*workflow.ActionEvent, error)

ToActionEvent unmarshals the Info bytes into a workflow.ActionEvent proto.

type Project added in v2.0.8

type Project struct {
	Identifier  string    `db:"identifier"`
	Name        string    `db:"name"`
	Description string    `db:"description"`
	Labels      []byte    `db:"labels"`
	State       *int32    `db:"state"`
	CreatedAt   time.Time `db:"created_at"`
	UpdatedAt   time.Time `db:"updated_at"`
}

type RecentAction

type RecentAction struct {
	TaskName string `db:"task_name"`
	Phase    int32  `db:"phase"`
}

type Run

type Run = Action

Run is a type alias for Action (runs are just actions with ParentActionName == nil)

type Task

type Task struct {
	TaskKey

	// Extracted from Name
	Environment  string `db:"environment"`
	FunctionName string `db:"function_name"`

	// Base fields
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`

	// Metadata
	DeployedBy            string         `db:"deployed_by"`
	TriggerName           sql.NullString `db:"trigger_name"`
	TotalTriggers         uint32         `db:"total_triggers"`
	ActiveTriggers        uint32         `db:"active_triggers"`
	TriggerAutomationSpec []byte         `db:"trigger_automation_spec"`
	TriggerTypes          pgtype.Bits    `db:"trigger_types"`
	EnvDescription        sql.NullString `db:"env_description" json:"env_description,omitempty"`
	ShortDescription      sql.NullString `db:"short_description" json:"short_description,omitempty"`

	// Spec
	TaskSpec []byte `db:"task_spec"`
}

Tasks models the TaskDetails from the task_definition.proto

type TaskCounts

type TaskCounts struct {
	// FilteredTotal is the number of tasks matching the applied filter
	FilteredTotal uint32 `db:"filtered_total"`
	// Total is the total number of tasks without any filters
	Total uint32 `db:"total"`
}

type TaskGroup

type TaskGroup struct {
	TaskName        string  `db:"task_name"`
	EnvironmentName *string `db:"environment_name"`
	TaskShortName   *string `db:"task_short_name"`

	ActionCount           int64      `db:"action_count"`
	LatestCreatedAt       time.Time  `db:"latest_created_at"`
	LastRunEndedAt        *time.Time `db:"last_run_ended_at"`
	AverageFailurePercent float64    `db:"average_failure_percent"`
	AverageDurationMs     *float64   `db:"average_duration_ms"`
	CreatedByList         []string   `db:"created_by_list"`
	RecentPhases          []int32    `db:"-"`

	// Error counts from action_events table by error kind
	UserErrorCount        int64 `db:"user_error_count"`
	SystemErrorCount      int64 `db:"system_error_count"`
	UnspecifiedErrorCount int64 `db:"unspecified_error_count"`
}

type TaskGroupNotificationPayload

type TaskGroupNotificationPayload struct {
	Project         string
	Domain          string
	TaskName        string
	EnvironmentName *string
}

type TaskKey

type TaskKey struct {
	Project string `db:"project"`
	Domain  string `db:"domain"`
	Name    string `db:"name"`
	Version string `db:"version"`
}

TaskKey is a composite key for a task

type TaskListResult

type TaskListResult struct {
	Tasks         []*Task
	FilteredTotal uint32
	Total         uint32
}

type TaskName

type TaskName struct {
	Project string
	Domain  string
	Name    string
}

TaskName is a composite key representing a task

type TaskSpec

type TaskSpec struct {
	// Base64 encoded digest used as a unique identifier for the task spec
	Digest string `db:"digest"`

	// Base fields
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`

	// Marshaled task spec
	Spec []byte `db:"spec"`
}

TaskSpec is the model for ALL action specs, including normal tasks, traces, conditional actions, etc.

func NewTaskSpecModel

func NewTaskSpecModel(ctx context.Context, spec *flyteWorkflow.TaskSpec) (*TaskSpec, error)

func NewTaskSpecModelFromTraceSpec

func NewTaskSpecModelFromTraceSpec(ctx context.Context, traceSpec *flyteWorkflow.TraceSpec) (*TaskSpec, error)

type TaskVersion

type TaskVersion struct {
	Version   string    `db:"version"`
	CreatedAt time.Time `db:"created_at"`
}

Models the TaskVersion response

type TaskWithCounts

type TaskWithCounts struct {
	Task
	TaskCounts
}

TaskWithCounts extends Task with count information for pagination

type Trigger added in v2.0.12

type Trigger struct {
	ID uint `db:"id"`

	// Trigger identity — unique constraint drives upsert
	Project  string `db:"project"`
	Domain   string `db:"domain"`
	TaskName string `db:"task_name"`
	Name     string `db:"name"`

	// Monotonically increasing counter; incremented on every write
	LatestRevision uint64 `db:"latest_revision"`

	// Serialized protos
	Spec           []byte `db:"spec"`
	AutomationSpec []byte `db:"automation_spec"`

	// Denormalized fields for cheap queries without deserializing protos
	TaskVersion    string `db:"task_version"`
	Active         bool   `db:"active"`
	AutomationType string `db:"automation_type"`

	// Identity
	DeployedBy sql.NullString `db:"deployed_by"`
	UpdatedBy  sql.NullString `db:"updated_by"`

	// Timestamps
	DeployedAt  time.Time    `db:"deployed_at"`
	UpdatedAt   time.Time    `db:"updated_at"`
	TriggeredAt sql.NullTime `db:"triggered_at"`
	DeletedAt   sql.NullTime `db:"deleted_at"`

	Description sql.NullString `db:"description"`
}

Trigger is the mutable latest-state row for a trigger. One row per (project, domain, task_name, name); updated in-place on each deploy/activate/delete. Mirrors the pattern used by Action (latest state) + ActionEvent (history).

func (Trigger) ToTaskKey added in v2.0.12

func (t Trigger) ToTaskKey() TaskKey

ToTaskKey returns the TaskKey this trigger is attached to.

type TriggerRevision added in v2.0.12

type TriggerRevision struct {
	// Composite PK: trigger identity + revision number
	Project  string `db:"project"`
	Domain   string `db:"domain"`
	TaskName string `db:"task_name"`
	Name     string `db:"name"`
	Revision uint64 `db:"revision"`

	// Snapshot of state at this revision
	Spec           []byte `db:"spec"`
	AutomationSpec []byte `db:"automation_spec"`

	TaskVersion    string `db:"task_version"`
	Active         bool   `db:"active"`
	AutomationType string `db:"automation_type"`

	DeployedBy sql.NullString `db:"deployed_by"`
	UpdatedBy  sql.NullString `db:"updated_by"`

	DeployedAt  time.Time    `db:"deployed_at"`
	UpdatedAt   time.Time    `db:"updated_at"`
	TriggeredAt sql.NullTime `db:"triggered_at"`
	DeletedAt   sql.NullTime `db:"deleted_at"`

	// What action produced this revision row
	// Values: TRIGGER_REVISION_ACTION_DEPLOY, _ACTIVATE, _DEACTIVATE, _DELETE
	Action string `db:"action"`

	CreatedAt time.Time `db:"created_at"`
}

TriggerRevision is an immutable snapshot appended on every state change. Mirrors the ActionEvent (append-only history) pattern.

Jump to

Keyboard shortcuts

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