Documentation ¶
Index ¶
- Variables
- func IsWorkDirValid(fl validator.FieldLevel) bool
- type HeartBeatSpec
- type TaskHandlerSpec
- type Worker
- func (w *Worker) AllowToSalvageOn(t time.Time) bool
- func (w *Worker) IsLostOn(t time.Time) bool
- func (w *Worker) SetFailed(t time.Time, reason WorkerReason) error
- func (w *Worker) SetLastHeartBeatAt(t time.Time) error
- func (w *Worker) SetSalvagedByAndOn(by uuid.UUID, on time.Time)
- func (w *Worker) SetSucceeded(t time.Time) error
- func (w *Worker) UpdateStatusIfLostOn(t time.Time)
- type WorkerPhase
- type WorkerReason
- type WorkerSpec
- type WorkerStatus
Constants ¶
This section is empty.
Variables ¶
View Source
var ( WorkerPhaseRunning WorkerPhase = "Running" WorkerPhaseSucceeded WorkerPhase = "Succeeded" WorkerPhaseFailed WorkerPhase = "Failed" WorkerReasonSuccess WorkerReason = "Success" WorkerReasonFailure WorkerReason = "Failure" WorkerReasonLost WorkerReason = "Lost" WorkerReasonSalvaged WorkerReason = "Salvaged" RegisterValidator = func(v *validator.Validate) { if err := v.RegisterValidation("isWorkDirValid", IsWorkDirValid); err != nil { panic(err) } } Validator = func() *validator.Validate { v := validator.New() RegisterValidator(v) return v }() )
Functions ¶
Types ¶
type HeartBeatSpec ¶
type HeartBeatSpec struct { SalvageDuration time.Duration `json:"salvageDuration" yaml:"salvageDuration" default:"15s" validate:"required"` ExpirationDuration time.Duration `json:"expirationDuration" yaml:"expirationDuration" default:"10s" validate:"required"` Interval time.Duration `json:"interval" yaml:"interval" default:"2s" validate:"required"` }
type TaskHandlerSpec ¶
type Worker ¶
type Worker struct { UID uuid.UUID `json:"uid" yaml:"uid"` QueueUID uuid.UUID `json:"queueUID" yaml:"queueUID"` Spec WorkerSpec Status WorkerStatus }
func (*Worker) UpdateStatusIfLostOn ¶
type WorkerPhase ¶
type WorkerPhase string
type WorkerReason ¶
type WorkerReason string
type WorkerSpec ¶
type WorkerSpec struct { Name string `json:"name" yaml:"name" default:"-" validate:"required,min=1,max=256"` Concurrency int `json:"concurrency" yaml:"concurrency" default:"1" validate:"required,min=1"` TaskHandler TaskHandlerSpec `json:"taskHandler" yaml:"taskHandler" validate:"required"` HeartBeat HeartBeatSpec `json:"heartBeat" yaml:"heartBeat" validate:"required"` ExitOnSuspend bool `json:"exitOnSuspend" yaml:"exitOnSuspend" default:"true"` ExitOnEmpty bool `json:"exitOnEmpty" yaml:"exitOnEmpty" default:"false"` ExitOnEmptyGracePeriod time.Duration `json:"exitOnEmptyGracePeriod" yaml:"exitOnEmptyGracePeriod" default:"10s"` NumTasks int `json:"numTasks" yaml:"numTasks" default:"100"` WorkDir string `json:"workDir" yaml:"workDir" default:"/tmp" validate:"isWorkDirValid,required"` }
func (WorkerSpec) Validate ¶
func (spec WorkerSpec) Validate() error
type WorkerStatus ¶
type WorkerStatus struct { Phase WorkerPhase `json:"phase" yaml:"phase"` Reason WorkerReason `json:"reason,omitempty" yaml:"reason,omitempty"` StartedAt time.Time `json:"startedAt" yaml:"startedAt"` FinishedAt time.Time `json:"finishedAt,omitempty" yaml:"finishedAt,omitempty"` LastHeartBeatAt time.Time `json:"lastHeartBeatAt,omitempty" yaml:"lastHeartBeatAt,omitempty"` SalvagedBy *uuid.UUID `json:"salvagedBy,omitempty" yaml:"salvagedBy,omitempty"` SalvagedAt *time.Time `json:"salvagedAt,omitempty" yaml:"salvagedAt,omitempty"` }
Click to show internal directories.
Click to hide internal directories.