Documentation ¶
Index ¶
- Constants
- type FutureJobResult
- type Job
- 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 (job *Job) Validate(taskrepo *taskrepo.TaskRepository) error
- type JobResult
- type JobStatus
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 FutureJobResult ¶
type FutureJobResult struct {
Result chan JobResult
}
FutureJobResult is a JobResult that may not yet have become available and can be Wait()'ed on.
func (FutureJobResult) Wait ¶
func (f FutureJobResult) Wait() JobResult
Wait waits for JobResult to become available and returns it.
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"` // 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 string, timeout int, runAt *time.Time, createdAt *time.Time, taskParams map[string]interface{}) *Job
NewJob initializes and returns a new Job instance.
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.