Documentation ¶
Index ¶
- Constants
- type Job
- func (j *Job) BelongsToPipeline() bool
- func (j *Job) HasNext() bool
- func (j *Job) IsScheduled() bool
- func (j *Job) MarkCompleted(completedAt *time.Time)
- func (j *Job) MarkFailed(failedAt *time.Time, reason string)
- func (j *Job) MarkScheduled(scheduledAt *time.Time)
- func (j *Job) MarkStarted(startedAt *time.Time)
- func (j *Job) SetDuration()
- func (j *Job) Validate(taskrepo *taskrepo.TaskRepository) error
- type JobResult
- type JobStatus
- type Pipeline
- func (p *Pipeline) IsScheduled() bool
- func (p *Pipeline) MarkCompleted(completedAt *time.Time)
- func (p *Pipeline) MarkFailed(failedAt *time.Time)
- func (p *Pipeline) MarkStarted(startedAt *time.Time)
- func (p *Pipeline) MergeJobsInOne()
- func (p *Pipeline) SetDuration()
- func (p *Pipeline) UnmergeJobs()
- func (p *Pipeline) Validate() error
Constants ¶
const ( Undefined JobStatus = iota // 0 Pending // 1 Scheduled // 2 InProgress // 3 Completed // 4 Failed // 5 PENDING = "PENDING" SCHEDULED = "SCHEDULED" IN_PROGRESS = "IN_PROGRESS" COMPLETED = "COMPLETED" FAILED = "FAILED" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct { // ID is the auto-generated job identifier in UUID4 format. ID string `json:"id"` // Name is the name of the job. Name string `json:"name"` // PipelineID is the auto-generated pipeline identifier in UUID4 format. // It will be empty if the job does not belong to a pipeline. PipelineID string `json:"pipeline_id,omitempty"` // NextJobID is the ID of the job that should run next in the pipeline, if any. NextJobID string `json:"next_job_id,omitempty"` // UsePreviousResults indicates where the job should use the // results of the previous job in the pipeline or not. UsePreviousResults bool `json:"use_previous_results,omitempty"` // Next points to the next job of the pipeline, if any. Next *Job `json:"next,omitempty"` // TaskName is the name of the task to be executed. TaskName string `json:"task_name"` // TaskParams are the required parameters for the task assigned to the specific job. TaskParams map[string]interface{} `json:"task_params,omitempty"` // Timeout is the time in seconds after which the job task will be interrupted. Timeout int `json:"timeout,omitempty"` // Description gives some information about the job. Description string `json:"description,omitempty"` // Status represents the status of the job. Status JobStatus `json:"status"` // FailureReason holds the error message that led to the job failure, if any. FailureReason string `json:"failure_reason,omitempty"` // RunAt is the UTC timestamp indicating the time for the job to run. RunAt *time.Time `json:"run_at,omitempty"` // ScheduledAt is the UTC timestamp indicating the time that the job got scheduled. ScheduledAt *time.Time `json:"scheduled_at,omitempty"` // CreatedAt is the UTC timestamp of the job creation. CreatedAt *time.Time `json:"created_at,omitempty"` // StartedAt is the UTC timestamp of the moment the job started. StartedAt *time.Time `json:"started_at,omitempty"` // CompletedAt is the UTC timestamp of the moment the job finished. CompletedAt *time.Time `json:"completed_at,omitempty"` // Duration indicates how much the job took to complete. Duration *time.Duration `json:"duration,omitempty"` }
Job represents an async task.
func NewJob ¶
func NewJob( uuid, name, taskName, description, pipelineID, nextJobID string, timeout int, runAt *time.Time, createdAt *time.Time, usePreviousResults bool, taskParams map[string]interface{}) *Job
NewJob initializes and returns a new Job instance.
func (*Job) BelongsToPipeline ¶ added in v0.8.0
func (*Job) IsScheduled ¶ added in v0.8.0
func (*Job) MarkCompleted ¶
MarkCompleted updates the status and timestamp at the moment the job finished.
func (*Job) MarkFailed ¶
MarkFailed updates the status and timestamp at the moment the job failed.
func (*Job) MarkScheduled ¶
MarkScheduled updates the status and timestamp at the moment the job got scheduled.
func (*Job) MarkStarted ¶
MarkStarted updates the status and timestamp at the moment the job started.
func (*Job) SetDuration ¶
func (j *Job) SetDuration()
SetDuration sets the duration of the job if it's completed of failed.
type JobResult ¶
type JobResult struct { JobID string `json:"job_id"` Metadata interface{} `json:"metadata,omitempty"` Error string `json:"error,omitempty"` }
JobResult contains the result of a job.
type JobStatus ¶
type JobStatus int
JobStatus holds a value for job status ranging from 1 to 5.
func (*JobStatus) MarshalJSON ¶
Marshaling for JSON representation.
func (*JobStatus) UnmarshalJSON ¶
Unmarshaling for JSON representation.
type Pipeline ¶ added in v0.8.0
type Pipeline struct { // ID is the auto-generated pipeline identifier in UUID4 format. ID string `json:"id"` // Name is the name of the pipeline. Name string `json:"name"` // Description gives some information about the pipeline. Description string `json:"description,omitempty"` // Jobs represents the jobs included to this pipeline. Jobs []*Job `json:"jobs,omitempty"` // Status represents the status of the pipeline. // Jobs propagate their finite status to the pipeline. Status JobStatus `json:"status"` // RunAt is the UTC timestamp indicating the time for the pipeline to run. // This property will be propagated to the first job of the pipeline. RunAt *time.Time `json:"run_at,omitempty"` // CreatedAt is the UTC timestamp of the pipeline creation. CreatedAt *time.Time `json:"created_at,omitempty"` // StartedAt is the UTC timestamp of the moment the pipeline started. StartedAt *time.Time `json:"started_at,omitempty"` // CompletedAt is the UTC timestamp of the moment the pipeline finished. CompletedAt *time.Time `json:"completed_at,omitempty"` // Duration indicates how much the pipeline took to complete. Duration *time.Duration `json:"duration,omitempty"` }
Pipeline represents a sequence of async tasks.
func NewPipeline ¶ added in v0.8.0
func (*Pipeline) IsScheduled ¶ added in v0.8.0
func (*Pipeline) MarkCompleted ¶ added in v0.8.0
MarkCompleted updates the status and timestamp at the moment the pipeline finished.
func (*Pipeline) MarkFailed ¶ added in v0.8.0
MarkFailed updates the status and timestamp at the moment the pipeline failed.
func (*Pipeline) MarkStarted ¶ added in v0.8.0
MarkStarted updates the status and timestamp at the moment the pipeline started.
func (*Pipeline) MergeJobsInOne ¶ added in v0.8.0
func (p *Pipeline) MergeJobsInOne()
func (*Pipeline) SetDuration ¶ added in v0.8.0
func (p *Pipeline) SetDuration()
SetDuration sets the duration of the pipeline if it's completed of failed.
func (*Pipeline) UnmergeJobs ¶ added in v0.8.0
func (p *Pipeline) UnmergeJobs()