Documentation
¶
Index ¶
- Constants
- type Connection
- type CreateDataReq
- type CreateTaskComponentReq
- type CreateTaskGroupReq
- type CreateTaskReq
- type CreateWorkflowReq
- type CreateWorkflowScheduleReq
- type Data
- type EventLog
- type EventLogs
- type GetWorkflowTemplate
- type ImportError
- type ImportErrors
- type RunScriptReq
- type SSHTarget
- type ScriptResult
- type SimpleMsg
- type SleepTimeReq
- type Spec
- type TBSSHKeyInfo
- type Task
- type TaskClearOption
- type TaskComponent
- type TaskDBModel
- type TaskDirectly
- type TaskGroup
- type TaskGroupDBModel
- type TaskGroupDirectly
- type TaskInstance
- type TaskInstanceReference
- type TaskLog
- type TaskSnapshot
- type Workflow
- type WorkflowRun
- type WorkflowSchedule
- type WorkflowScheduleStatus
- type WorkflowScheduleType
- type WorkflowStatus
- type WorkflowTemplate
- type WorkflowVersion
Constants ¶
const (
WorkflowSpecVersion_1_0 = "1.0"
)
const (
WorkflowSpecVersion_LATEST = WorkflowSpecVersion_1_0
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
ID string `json:"id" yaml:"id" mapstructure:"id" validate:"required"`
Type string `json:"type" yaml:"type" mapstructure:"type" validate:"required"`
Description string `json:"description" yaml:"description" mapstructure:"description"`
Host string `json:"host" yaml:"host" mapstructure:"host" validate:"required"`
Port int32 `json:"port" yaml:"port" mapstructure:"port" `
Schema string `json:"schema" yaml:"schema" mapstructure:"schema"`
Login string `json:"login" yaml:"login" mapstructure:"login"`
Password string `json:"password" yaml:"password" mapstructure:"password"`
Extra string `json:"extra" yaml:"extra" mapstructure:"extra"`
}
type CreateDataReq ¶ added in v0.2.0
type CreateDataReq struct {
Description string `json:"description" mapstructure:"description"`
TaskGroups []CreateTaskGroupReq `json:"task_groups" mapstructure:"task_groups" validate:"required"`
}
func (*CreateDataReq) Scan ¶ added in v0.2.0
func (d *CreateDataReq) Scan(value interface{}) error
type CreateTaskComponentReq ¶ added in v0.2.0
type CreateTaskGroupReq ¶ added in v0.2.0
type CreateTaskGroupReq struct {
Name string `json:"name" mapstructure:"name" validate:"required"`
Description string `json:"description" mapstructure:"description"`
Tasks []CreateTaskReq `json:"tasks" mapstructure:"tasks" validate:"required"`
}
type CreateTaskReq ¶ added in v0.2.0
type CreateTaskReq struct {
Name string `json:"name" mapstructure:"name" validate:"required"`
TaskComponent string `json:"task_component" mapstructure:"task_component" validate:"required"`
Spec Spec `json:"spec,omitempty" mapstructure:"spec"`
Dependencies []string `json:"dependencies" mapstructure:"dependencies"`
}
type CreateWorkflowReq ¶ added in v0.2.0
type CreateWorkflowReq struct {
SpecVersion string `json:"spec_version" mapstructure:"spec_version"`
Name string `json:"name" mapstructure:"name" validate:"required"`
Data CreateDataReq `json:"data" mapstructure:"data" validate:"required"`
}
type CreateWorkflowScheduleReq ¶ added in v0.5.1
type CreateWorkflowScheduleReq struct {
RunAt *time.Time `json:"run_at,omitempty" mapstructure:"run_at"`
Cron *string `json:"cron,omitempty" mapstructure:"cron"`
}
CreateWorkflowScheduleReq is the body for POST /workflow/{wfId}/schedule. Exactly one of RunAt / Cron must be provided. RunAt creates a one-shot schedule, Cron creates a recurring schedule.
type Data ¶
type Data struct {
Description string `json:"description" mapstructure:"description"`
TaskGroups []TaskGroup `json:"task_groups" mapstructure:"task_groups" validate:"required"`
}
Data is the graph container serialized into the `data` column of the workflows table (JSON-encoded via the Valuer/Scanner pair below).
type EventLog ¶ added in v0.2.1
type EventLog struct {
WorkflowRunID string `json:"workflow_run_id"`
RunID string `json:"run_id,omitempty"`
WorkflowID string `json:"workflow_id"`
TaskID string `json:"task_id"`
TaskName string `json:"task_name"`
IsDeletedTask bool `json:"is_deleted_task"`
Event string `json:"event,omitempty"`
When time.Time `json:"when,omitempty"`
Extra string `json:"extra,omitempty"`
}
type GetWorkflowTemplate ¶ added in v0.2.0
type GetWorkflowTemplate struct {
SpecVersion string `gorm:"column:spec_version" json:"spec_version" mapstructure:"spec_version" validate:"required"`
Name string `gorm:"index:,column:name,unique;type:text collate nocase" json:"name" mapstructure:"name" validate:"required"`
Data CreateDataReq `gorm:"column:data" json:"data" mapstructure:"data" validate:"required"`
}
type ImportError ¶ added in v0.5.2
type ImportError struct {
ImportErrorID int `json:"import_error_id"`
Timestamp time.Time `json:"timestamp,omitempty"`
Filename string `json:"filename,omitempty"`
BundleName string `json:"bundle_name,omitempty"`
StackTrace string `json:"stack_trace,omitempty"`
}
ImportError is a DAG import failure reported by Airflow's DAG processor.
type ImportErrors ¶ added in v0.5.2
type ImportErrors struct {
ImportErrors []ImportError `json:"import_errors"`
TotalEntries int `json:"total_entries"`
}
type RunScriptReq ¶ added in v0.4.1
type ScriptResult ¶ added in v0.4.1
type SleepTimeReq ¶ added in v0.4.1
type SleepTimeReq struct {
Time string `json:"time"` // Ex: 300 = 300sec, 1m 30s = 1min 30seconds, 1h 10m 15s = 1hour 10minutes 15seconds, 1d 1s = 1day 1second, No Input Default: 10s
}
type Spec ¶ added in v0.5.1
Spec is a free-form key/value map persisted as JSON. Catalog (conf/task_types.yaml) defines which keys are valid per task type.
type TBSSHKeyInfo ¶ added in v0.4.1
type TBSSHKeyInfo struct {
PrivateKey string `json:"privateKey,omitempty"`
}
type Task ¶
type Task struct {
ID string `gorm:"primaryKey" json:"id" mapstructure:"id" validate:"required"`
Name string `json:"name" mapstructure:"name" validate:"required"`
TaskComponent string `json:"task_component" mapstructure:"task_component" validate:"required"`
Spec Spec `json:"spec,omitempty" mapstructure:"spec"`
Dependencies []string `json:"dependencies" mapstructure:"dependencies"`
IsDeletedTask bool `json:"is_deleted_task"`
}
Task is the domain/API representation of a task inside a workflow graph. The Spec map carries type-specific runtime values (validated against the catalog's task_schema for the referenced TaskComponent.Type).
type TaskClearOption ¶ added in v0.3.1
type TaskClearOption struct {
DryRun bool `json:"dryRun"`
TaskIds []string `json:"taskIds"`
IncludeDownstream bool `json:"includeDownstream"`
//IncludeFuture bool `json:"includeFuture"`
//IncludeParentdag bool `json:"includeParentdag"`
//IncludePast bool `json:"includePast"`
//IncludeSubdags bool `json:"includeSubdags"`
IncludeUpstream bool `json:"includeUpstream"`
OnlyFailed bool `json:"onlyFailed"`
OnlyRunning bool `json:"onlyRunning"`
// ResetDagRuns is a pointer so an omitted field can be told apart from an
// explicit false; see ResetDagRunsOrDefault.
ResetDagRuns *bool `json:"resetDagRuns,omitempty"`
}
func (TaskClearOption) ResetDagRunsOrDefault ¶ added in v0.6.2
func (o TaskClearOption) ResetDagRunsOrDefault() bool
ResetDagRunsOrDefault returns the reset_dag_runs value to send to Airflow. Airflow defaults reset_dag_runs to true, which puts a finished run back in the queue so the cleared tasks actually run again. When the caller omits the field, follow that default, except on a dry run where nothing is reset.
type TaskComponent ¶
type TaskComponent struct {
ID string `gorm:"primaryKey" json:"id" mapstructure:"id" validate:"required"`
Name string `gorm:"index:,column:name,unique;type:text collate nocase" json:"name" mapstructure:"name" validate:"required"`
Description string `gorm:"column:description" json:"description"`
Type string `gorm:"column:type;index" json:"type" mapstructure:"type" validate:"required"`
Spec Spec `gorm:"column:spec;type:text" json:"spec"`
IsExample bool `gorm:"column:is_example" json:"is_example" mapstructure:"is_example"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime:false" json:"created_at" mapstructure:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;autoCreateTime:false" json:"updated_at" mapstructure:"updated_at"`
}
TaskComponent is a reusable definition that workflow tasks can reference. Type points to a catalog entry (conf/task_types.yaml), Spec carries the component-level values for that type.
type TaskDBModel ¶ added in v0.2.0
type TaskDBModel struct {
ID string `gorm:"primaryKey" json:"id" mapstructure:"id" validate:"required"`
Name string `json:"name" mapstructure:"name" validate:"required"`
WorkflowID string `gorm:"column:workflow_id;index" json:"workflow_id" mapstructure:"workflow_id" validate:"required"`
WorkflowKey string `gorm:"column:workflow_key;index" json:"-" mapstructure:"-"`
TaskGroupID string `gorm:"column:task_group_id;index" json:"task_group_id" mapstructure:"task_group_id" validate:"required"`
TaskGroupKey string `gorm:"column:task_group_key;index" json:"-" mapstructure:"-"`
TaskKey string `gorm:"column:task_key;index" json:"-" mapstructure:"-"`
IsDeleted bool `gorm:"column:is_deleted;index;default:false" json:"-" mapstructure:"-"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"-" mapstructure:"-"`
}
TaskDBModel is the persistent representation of a task row.
type TaskDirectly ¶ added in v0.2.0
type TaskDirectly struct {
ID string `gorm:"primaryKey" json:"id" mapstructure:"id" validate:"required"`
WorkflowID string `json:"workflow_id" mapstructure:"workflow_id" validate:"required"`
TaskGroupID string `json:"task_group_id" mapstructure:"task_group_id" validate:"required"`
Name string `json:"name" mapstructure:"name" validate:"required"`
TaskComponent string `json:"task_component" mapstructure:"task_component" validate:"required"`
Spec Spec `json:"spec,omitempty" mapstructure:"spec"`
Dependencies []string `json:"dependencies" mapstructure:"dependencies"`
}
TaskDirectly is a flat variant used by the "direct create" path where a task is created with its workflow/task-group IDs embedded in the payload.
type TaskGroup ¶
type TaskGroup struct {
ID string `gorm:"primaryKey" json:"id" mapstructure:"id" validate:"required"`
Name string `json:"name" mapstructure:"name" validate:"required"`
Description string `json:"description" mapstructure:"description"`
Tasks []Task `json:"tasks" mapstructure:"tasks" validate:"required"`
}
type TaskGroupDBModel ¶ added in v0.2.0
type TaskGroupDBModel struct {
ID string `gorm:"primaryKey" json:"id" mapstructure:"id" validate:"required"`
Name string `json:"name" mapstructure:"name" validate:"required"`
WorkflowID string `gorm:"column:workflow_id;index" json:"workflow_id" mapstructure:"workflow_id" validate:"required"`
WorkflowKey string `gorm:"column:workflow_key;index" json:"-" mapstructure:"-"`
TaskGroupKey string `gorm:"column:task_group_key;index" json:"-" mapstructure:"-"`
IsDeleted bool `gorm:"column:is_deleted;index;default:false" json:"-" mapstructure:"-"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"-" mapstructure:"-"`
}
TaskGroupDBModel is the persistent representation of a task group row.
type TaskGroupDirectly ¶ added in v0.2.0
type TaskGroupDirectly struct {
ID string `json:"id" mapstructure:"id" validate:"required"`
WorkflowID string `json:"workflow_id" mapstructure:"workflow_id" validate:"required"`
Name string `json:"name" mapstructure:"name" validate:"required"`
Description string `json:"description" mapstructure:"description"`
Tasks []Task `json:"tasks" mapstructure:"tasks" validate:"required"`
}
type TaskInstance ¶ added in v0.2.1
type TaskInstance struct {
WorkflowRunID string `json:"workflow_run_id,omitempty"`
WorkflowID *string `json:"workflow_id,omitempty"`
DagID *string `json:"dag_id,omitempty"`
IsDeletedTask bool `json:"is_deleted_task"`
TaskID string `json:"task_id,omitempty"`
TaskName string `json:"task_name,omitempty"`
State string `json:"state,omitempty"`
StartDate time.Time `json:"start_date,omitempty"`
EndDate time.Time `json:"end_date,omitempty"`
DurationDate float64 `json:"duration_date"`
ExecutionDate time.Time `json:"execution_date,omitempty"`
TryNumber int `json:"try_number"`
IsSoftwareMigrationTask bool `json:"is_software_migration_task"`
SoftwareMigrationExecutionID string `json:"software_migration_execution_id,omitempty"`
}
TaskInstance mirrors an Airflow task instance state.
type TaskInstanceReference ¶ added in v0.2.1
type TaskInstanceReference struct {
// The task ID.
TaskId *string `json:"task_id,omitempty"`
TaskName string `json:"task_name,omitempty"`
// DB workflow ID.
WorkflowID *string `json:"workflow_id,omitempty"`
// The DAG ID.
DagID *string `json:"dag_id,omitempty"`
// The DAG run ID.
WorkflowRunID *string `json:"workflow_run_id,omitempty"`
ExecutionDate *string `json:"execution_date,omitempty"`
}
type TaskSnapshot ¶ added in v0.5.1
type TaskSnapshot struct {
ID string `gorm:"primaryKey" json:"id"`
WorkflowID string `gorm:"column:workflow_id;index:idx_task_snapshots_workflow_task,priority:1;index" json:"workflow_id"`
WorkflowKey string `gorm:"column:workflow_key;index" json:"workflow_key"`
TaskID string `gorm:"column:task_id;index:idx_task_snapshots_workflow_task,priority:2;index" json:"task_id"`
TaskKey string `gorm:"column:task_key;index" json:"task_key"`
TaskName string `gorm:"column:task_name;index" json:"task_name"`
TaskGroupID string `gorm:"column:task_group_id;index" json:"task_group_id"`
SnapshotType string `gorm:"column:snapshot_type;index" json:"snapshot_type"`
RawTask string `gorm:"column:raw_task;type:text" json:"raw_task"`
CapturedAt time.Time `gorm:"column:captured_at;index" json:"captured_at"`
}
TaskSnapshot preserves the raw payload of a deleted task for audit/history.
type Workflow ¶
type Workflow struct {
ID string `gorm:"primaryKey" json:"id" mapstructure:"id" validate:"required"`
WorkflowKey string `gorm:"column:workflow_key;index;unique" json:"-" mapstructure:"-"`
SpecVersion string `gorm:"column:spec_version" json:"spec_version" mapstructure:"spec_version" validate:"required"`
Name string `gorm:"column:name;type:text collate nocase" json:"name" mapstructure:"name" validate:"required"`
Data Data `gorm:"column:data" json:"data" mapstructure:"data" validate:"required"`
CurrentVersionID string `gorm:"column:current_version_id;index" json:"-" mapstructure:"-"`
IsDeleted bool `gorm:"column:is_deleted;index;default:false" json:"-" mapstructure:"-"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"-" mapstructure:"-"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime:false" json:"created_at" mapstructure:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;autoCreateTime:false" json:"updated_at" mapstructure:"updated_at"`
}
Workflow is the persistent root aggregate — the workflow record in DB.
type WorkflowRun ¶ added in v0.2.1
type WorkflowRun struct {
WorkflowRunID string `json:"workflow_run_id,omitempty"`
WorkflowID *string `json:"workflow_id,omitempty"`
DagID *string `json:"dag_id,omitempty"`
LogicalDate string `json:"logical_date,omitempty"`
ExecutionDate time.Time `json:"execution_date,omitempty"`
StartDate time.Time `json:"start_date,omitempty"`
EndDate time.Time `json:"end_date,omitempty"`
DurationDate float64 `json:"duration_date,omitempty"`
DataIntervalStart time.Time `json:"data_interval_start,omitempty"`
DataIntervalEnd time.Time `json:"data_interval_end,omitempty"`
LastSchedulingDecision time.Time `json:"last_scheduling_decision,omitempty"`
RunType string `json:"run_type,omitempty"`
State string `json:"state,omitempty"`
ExternalTrigger *bool `json:"external_trigger,omitempty"`
Conf map[string]interface{} `json:"conf,omitempty"`
Note string `json:"note,omitempty"`
}
WorkflowRun mirrors an Airflow DAG run snapshot returned from the scheduler. Not persisted in cm-cicada's DB — these records live in Airflow.
type WorkflowSchedule ¶ added in v0.5.1
type WorkflowSchedule struct {
ID string `gorm:"primaryKey;column:id" json:"id"`
WorkflowID string `gorm:"column:workflow_id;index;not null" json:"workflow_id"`
Type WorkflowScheduleType `gorm:"column:type;not null;default:once" json:"type"`
RunAt *time.Time `gorm:"column:run_at" json:"run_at,omitempty"`
Cron *string `gorm:"column:cron" json:"cron,omitempty"`
Status WorkflowScheduleStatus `gorm:"column:status;not null;default:active" json:"status"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
}
WorkflowSchedule records a scheduled execution of a workflow. The actual scheduling is delegated to Airflow via DAG metadata — cm-cicada only persists the intent so it survives restarts and is queryable.
One of RunAt / Cron is set depending on Type:
- Type="once": RunAt set, Cron nil. Airflow gets schedule="@once" + start_date=RunAt + catchup=false.
- Type="cron": Cron set, RunAt nil. Airflow gets schedule=<cron> + catchup=false.
At most one row per workflow_id is in active state at a time, regardless of type, because the Airflow DAG only carries a single schedule value.
func (WorkflowSchedule) TableName ¶ added in v0.5.1
func (WorkflowSchedule) TableName() string
type WorkflowScheduleStatus ¶ added in v0.5.1
type WorkflowScheduleStatus string
WorkflowScheduleStatus is the lifecycle state of a WorkflowSchedule row. Transitions: active -> canceled (user cancel) | active -> executed (Airflow ran it; only applies to type="once" — cron schedules stay active until canceled).
const ( WorkflowScheduleStatusActive WorkflowScheduleStatus = "active" WorkflowScheduleStatusCanceled WorkflowScheduleStatus = "canceled" WorkflowScheduleStatusExecuted WorkflowScheduleStatus = "executed" )
type WorkflowScheduleType ¶ added in v0.5.1
type WorkflowScheduleType string
WorkflowScheduleType discriminates one-shot vs recurring schedules.
const ( WorkflowScheduleTypeOnce WorkflowScheduleType = "once" WorkflowScheduleTypeCron WorkflowScheduleType = "cron" )
type WorkflowStatus ¶ added in v0.3.1
type WorkflowTemplate ¶
type WorkflowTemplate struct {
ID string `gorm:"primaryKey" json:"id" mapstructure:"id" validate:"required"`
SpecVersion string `gorm:"column:spec_version" json:"spec_version" mapstructure:"spec_version" validate:"required"`
Name string `gorm:"index:,column:name,unique;type:text collate nocase" json:"name" mapstructure:"name" validate:"required"`
Data CreateDataReq `gorm:"column:data" json:"data" mapstructure:"data" validate:"required"`
}
type WorkflowVersion ¶ added in v0.2.3
type WorkflowVersion struct {
ID string `gorm:"primaryKey" json:"id" mapstructure:"id" validate:"required"`
SpecVersion string `gorm:"column:spec_version" json:"spec_version" mapstructure:"spec_version" validate:"required"`
WorkflowID string `gorm:"column:workflowId;index" json:"workflowId" mapstructure:"workflowId" validate:"required"`
VersionNo int `gorm:"column:version_no;index" json:"version_no" mapstructure:"version_no"`
RawData Workflow `gorm:"column:raw_data" json:"data" mapstructure:"data"`
Action string `gorm:"column:action" json:"action" mapstructure:"action" validate:"required"`
SourceType string `gorm:"column:source_type" json:"source_type,omitempty" mapstructure:"source_type"`
SourceTemplateID string `gorm:"column:source_template_id" json:"source_template_id,omitempty" mapstructure:"source_template_id"`
CreatedAt time.Time `gorm:"column:created_at" json:"created_at" mapstructure:"created_at"`
}
WorkflowVersion preserves a snapshot of a Workflow at a given revision.