task

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskPhasePending    TaskPhase = "Pending"
	TaskPhaseReceived   TaskPhase = "Received"
	TaskPhaseProcessing TaskPhase = "Processing"
	TaskPhaseSucceeded  TaskPhase = "Succeeded"
	TaskPhaseFailed     TaskPhase = "Failed"

	TaskResultSuccess TaskResultType = "Success"
	TaskResultFailure TaskResultType = "Failure"

	TaskResultReasonSucceded      TaskResultReason = "Succeeded"
	TaskResultReasonSignaled      TaskResultReason = "Signaled"
	TaskResultReasonTimeout       TaskResultReason = "Timeout"
	TaskResultReasonFailed        TaskResultReason = "Failed"
	TaskResultReasonInternalError TaskResultReason = "InternalError"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Task

type Task struct {
	// TODO change the type to uuid.UUID
	UID       string     `json:"uid" yaml:"uid"`
	ParentUID *string    `json:"parentUID,omitempty" yaml:"parentUID,omitempty"`
	Spec      TaskSpec   `json:"spec" yaml:"spec"`
	Status    TaskStatus `json:"status" yaml:"status"`
}

func NewTask

func NewTask(spec TaskSpec, parent *Task) *Task

func (*Task) IsWorkerLost

func (t *Task) IsWorkerLost(defaultTimeoutSeconds int) bool

func (*Task) RecordFailure

func (t *Task) RecordFailure(reason TaskResultReason, payload *string, message *string, historyLengthLimit int) (bool, error)

func (*Task) SetProcessing

func (t *Task) SetProcessing() error

func (*Task) SetReceived

func (t *Task) SetReceived(workerName, workerUID string) error

func (*Task) SetSalvagedByOn

func (t *Task) SetSalvagedByOn(by uuid.UUID, on time.Time) bool

func (*Task) SetSuccess

func (t *Task) SetSuccess(payload *string, message *string, historyLengthLimit int) error

type TaskPhase

type TaskPhase string

type TaskRecord

type TaskRecord struct {
	WorkerUID  string      `json:"workerUID" yaml:"workerUID"`
	WorkerName string      `json:"workerName" yaml:"workerName"`
	ProcessUID string      `json:"processUID" yaml:"processUID"`
	ReceivedAt time.Time   `json:"receivedAt" yaml:"receivedAt"`
	StartedAt  *time.Time  `json:"startedAt,omitempty" yaml:"startedAt,omitempty"`
	FinishedAt *time.Time  `json:"finishedAt,omitempty" yaml:"finishedAt,omitempty"`
	Result     *TaskResult `json:"result,omitempty" yaml:"result,omitempty"`
	SalvagedBy *uuid.UUID  `json:"salvagedBy,omitempty" yaml:"salvagedBy,omitempty"`
	SalvagedAt *time.Time  `json:"salvagedAt,omitempty" yaml:"salvagedAt,omitempty"`
}

type TaskResult

type TaskResult struct {
	Type    TaskResultType   `json:"type" yaml:"type"`
	Reason  TaskResultReason `json:"reason" yaml:"reason"`
	Message *string          `json:"message,omitempty" yaml:"message,omitempty"`
	Payload *string          `json:"payload,omitempty" yaml:"payload,omitempty"`
}

type TaskResultReason

type TaskResultReason string

type TaskResultType

type TaskResultType string

type TaskSpec

type TaskSpec struct {
	Name           string `json:"name" yaml:"name,omitempty"`
	Payload        string `json:"payload" yaml:"payload"`
	RetryLimit     int    `json:"retryLimit,omitempty" yaml:"retryLimit,omitempty"`
	TimeoutSeconds int    `json:"timeoutSeconds,omitempty" yaml:"timeoutSeconds,omitempty"`
}

func (TaskSpec) ActualTimeout

func (s TaskSpec) ActualTimeout(defaultTimeout time.Duration) time.Duration

type TaskStatus

type TaskStatus struct {
	Phase         TaskPhase    `json:"phase" yaml:"phase"`
	CreatedAt     time.Time    `json:"createdAt" yaml:"createdAt"`
	CurrentRecord *TaskRecord  `json:"currentWork,omitempty" yaml:"currentWork,omitempty"`
	FailureCount  int          `json:"failureCount" yaml:"failureCount"`
	SalvageCount  int          `json:"salvageCount" yaml:"salvageCount"`
	History       []TaskRecord `json:"history,omitempty" yaml:"history,omitempty"`
}

Jump to

Keyboard shortcuts

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