Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ExecDAO is the global execution dao ExecDAO = NewExecutionDAO() )
Functions ¶
func RegisterExecutionStatusChangePostFunc ¶
func RegisterExecutionStatusChangePostFunc(vendor string, fc ExecutionStatusChangePostFunc)
Types ¶
type Execution ¶
type Execution struct { ID int64 `orm:"pk;auto;column(id)"` VendorType string `orm:"column(vendor_type)"` VendorID int64 `orm:"column(vendor_id)"` // In most of cases, the status should be calculated from the referenced tasks. // When the execution contains no task or failed to create tasks, the status should // be set manually Status string `orm:"column(status)"` StatusMessage string `orm:"column(status_message)"` Trigger string `orm:"column(trigger)"` ExtraAttrs string `orm:"column(extra_attrs)"` // json string StartTime time.Time `orm:"column(start_time)" sort:"default:desc"` UpdateTime time.Time `orm:"column(update_time)"` EndTime time.Time `orm:"column(end_time)"` Revision int64 `orm:"column(revision)"` }
Execution database model
type ExecutionDAO ¶
type ExecutionDAO interface { // Count returns the total count of executions according to the query // Query the "ExtraAttrs" by setting 'query.Keywords["ExtraAttrs.key"]="value"' Count(ctx context.Context, query *q.Query) (count int64, err error) // List the executions according to the query // Query the "ExtraAttrs" by setting 'query.Keywords["ExtraAttrs.key"]="value"' List(ctx context.Context, query *q.Query) (executions []*Execution, err error) // Get the specified execution Get(ctx context.Context, id int64) (execution *Execution, err error) // Create an execution Create(ctx context.Context, execution *Execution) (id int64, err error) // Update the specified execution. Only the properties specified by "props" will be updated if it is set Update(ctx context.Context, execution *Execution, props ...string) (err error) // Delete the specified execution Delete(ctx context.Context, id int64) (err error) // GetMetrics returns the task metrics for the specified execution GetMetrics(ctx context.Context, id int64) (metrics *Metrics, err error) // RefreshStatus refreshes the status of the specified execution according to it's tasks. If it's status // is final, update the end time as well // If the status is changed, the returning "statusChanged" is set as "true" and the current status indicates // the changed status RefreshStatus(ctx context.Context, id int64) (statusChanged bool, currentStatus string, err error) // AsyncRefreshStatus refreshes the status of the specified execution in the async mode, which will register // a update flag in the redis and then wait for global periodic job to scan and update the status to db finally. AsyncRefreshStatus(ctx context.Context, id int64, vendor string) (err error) }
ExecutionDAO is the data access object interface for execution
func NewExecutionDAO ¶
func NewExecutionDAO() ExecutionDAO
NewExecutionDAO returns an instance of ExecutionDAO
type ExecutionStatusChangePostFunc ¶
type ExecutionStatusChangePostFunc func(ctx context.Context, executionID int64, status string) (err error)
ExecutionStatusChangePostFunc is the function called after the execution status changed
type Metrics ¶
type Metrics struct { TaskCount int64 `json:"task_count"` SuccessTaskCount int64 `json:"success_task_count"` ErrorTaskCount int64 `json:"error_task_count"` PendingTaskCount int64 `json:"pending_task_count"` RunningTaskCount int64 `json:"running_task_count"` ScheduledTaskCount int64 `json:"scheduled_task_count"` StoppedTaskCount int64 `json:"stopped_task_count"` }
Metrics is the task metrics for one execution
type StatusCount ¶
StatusCount model
type Task ¶
type Task struct { ID int64 `orm:"pk;auto;column(id)"` VendorType string `orm:"column(vendor_type)"` ExecutionID int64 `orm:"column(execution_id)"` JobID string `orm:"column(job_id)"` Status string `orm:"column(status)"` StatusCode int `orm:"column(status_code)"` StatusRevision int64 `orm:"column(status_revision)"` StatusMessage string `orm:"column(status_message)"` RunCount int32 `orm:"column(run_count)"` ExtraAttrs string `orm:"column(extra_attrs)"` // json string CreationTime time.Time `orm:"column(creation_time)"` StartTime time.Time `orm:"column(start_time)"` UpdateTime time.Time `orm:"column(update_time)"` EndTime time.Time `orm:"column(end_time)"` }
Task database model
func (*Task) GetDefaultSorts ¶
GetDefaultSorts specifies the default sorts
type TaskDAO ¶
type TaskDAO interface { // Count returns the total count of tasks according to the query // Query the "ExtraAttrs" by setting 'query.Keywords["ExtraAttrs.key"]="value"' Count(ctx context.Context, query *q.Query) (count int64, err error) // List the tasks according to the query // Query the "ExtraAttrs" by setting 'query.Keywords["ExtraAttrs.key"]="value"' List(ctx context.Context, query *q.Query) (tasks []*Task, err error) // Get the specified task Get(ctx context.Context, id int64) (task *Task, err error) // Create a task Create(ctx context.Context, task *Task) (id int64, err error) // Update the specified task. Only the properties specified by "props" will be updated if it is set Update(ctx context.Context, task *Task, props ...string) (err error) // UpdateStatus updates the status of task UpdateStatus(ctx context.Context, id int64, status string, statusRevision int64) (err error) // Delete the specified task Delete(ctx context.Context, id int64) (err error) // ListStatusCount lists the status count for the tasks reference the specified execution ListStatusCount(ctx context.Context, executionID int64) (statusCounts []*StatusCount, err error) // GetMaxEndTime gets the max end time for the tasks references the specified execution GetMaxEndTime(ctx context.Context, executionID int64) (endTime time.Time, err error) // UpdateStatusInBatch updates the status of tasks in batch UpdateStatusInBatch(ctx context.Context, jobIDs []string, status string, batchSize int) (err error) // ExecutionIDsByVendorAndStatus retrieve the execution id by vendor status ExecutionIDsByVendorAndStatus(ctx context.Context, vendorType, status string) ([]int64, error) // ListScanTasksByReportUUID lists scan tasks by report uuid, although it's a specific case but it will be // more suitable to support multi database in the future. ListScanTasksByReportUUID(ctx context.Context, uuid string) (tasks []*Task, err error) }
TaskDAO is the data access object interface for task
Click to show internal directories.
Click to hide internal directories.