job

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownMessageType     = errors.New("unknown message type")
	ErrJobAlreadyExist        = errors.New("job is already exist")
	ErrJobNotFound            = errors.New("job is not found")
	ErrNotSupportedTaskStatus = errors.New("not supported task status")
)

Functions

This section is empty.

Types

type BaseJob

type BaseJob struct {
	Name string
	ID   uuid.UUID

	Tasks []Task
}

func (*BaseJob) GetName

func (j *BaseJob) GetName() string

func (*BaseJob) Init

func (j *BaseJob) Init()

func (*BaseJob) IsDone

func (j *BaseJob) IsDone() bool

func (*BaseJob) IsFailed

func (j *BaseJob) IsFailed() bool

func (*BaseJob) OnTaskDone

func (j *BaseJob) OnTaskDone(doneTask Task) []Task

func (*BaseJob) ReadyToRun

func (j *BaseJob) ReadyToRun() []Task

func (*BaseJob) UUID

func (j *BaseJob) UUID() uuid.UUID

type BaseTaskDependency

type BaseTaskDependency struct {
	// contains filtered or unexported fields
}

func NewBaseTaskDependency

func NewBaseTaskDependency(taskStatus TaskStatus, dependsOn []uuid.UUID) *BaseTaskDependency

func (*BaseTaskDependency) CancelledBy

func (t *BaseTaskDependency) CancelledBy() uuid.UUID

func (*BaseTaskDependency) DependsDone

func (t *BaseTaskDependency) DependsDone(taskId uuid.UUID) bool

func (*BaseTaskDependency) DependsFailed

func (t *BaseTaskDependency) DependsFailed(taskId uuid.UUID) bool

func (*BaseTaskDependency) IsCancelling

func (t *BaseTaskDependency) IsCancelling() bool

func (*BaseTaskDependency) IsReadyToRun

func (t *BaseTaskDependency) IsReadyToRun() bool

type InitJobProvider

type InitJobProvider interface {
	RecoverJobs() (jobs []Job, err error)
}

type Job

type Job interface {
	server.NamedElement

	UUID() uuid.UUID

	Init()
	// return ready to run tasks
	OnTaskDone(task Task) []Task
	ReadyToRun() []Task

	IsFailed() bool
	IsDone() bool
}

type JobHandler

type JobHandler struct {
	// contains filtered or unexported fields
}

func (*JobHandler) Handle

func (h *JobHandler) Handle(msg server.NamedElement) error

func (*JobHandler) Init

func (h *JobHandler) Init(setter server.GlobalSetter) error

func (*JobHandler) PostInit

func (h *JobHandler) PostInit(getter server.GlobalGetter) error

type SubTask

type SubTask interface {
	server.NamedElement

	TaskStatus

	UUID() uuid.UUID
	JobID() uuid.UUID

	Cancel(reason string)
}

type Task

type Task interface {
	SubTask
	TaskDependency
}

type TaskDependency

type TaskDependency interface {
	IsReadyToRun() bool
	IsCancelling() bool
	CancelledBy() uuid.UUID

	// return true if the task is ready to run
	DependsDone(uuid.UUID) bool
	// return true if the task is ready to run
	DependsFailed(uuid.UUID) bool
}

type TaskStatus

type TaskStatus interface {
	IsPending() bool
	IsRunning() bool
	IsFailed() bool
	IsDone() bool
}

Jump to

Keyboard shortcuts

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