scheduler

package
v0.0.0-...-1b0f315 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storer

type Storer interface {
	EnqueueTask(task *Task) error
	DequeueTask() (*Task, error)
}

type Task

type Task struct {
	Id         uuid.UUID   `json:"id"`
	Name       string      `json:"name"`
	Status     TaskStatus  `json:"status"`
	Details    interface{} `json:"details,omitempty"`
	Error      string      `json:"error,omitempty"`
	EnqueuedAt time.Time   `json:"enqueued_at,omitempty"`
	StartedAt  time.Time   `json:"started_at,omitempty"`
	FinishedAt time.Time   `json:"finished_at,omitempty"`
}

func NewTask

func NewTask(name string, details interface{}) Task

type TaskFunc

type TaskFunc interface {
	Execute(task *Task) (*Task, error)
}

type TaskScheduler

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

func NewTaskScheduler

func NewTaskScheduler(taskStorage Storer, logger logging.Logger) TaskScheduler

func (*TaskScheduler) ProcessTasks

func (s *TaskScheduler) ProcessTasks()

func (*TaskScheduler) RegisterListener

func (s *TaskScheduler) RegisterListener(taskName string, taskFunc TaskFunc)

type TaskStatus

type TaskStatus string
const (
	Enqueued   TaskStatus = "enqueued"
	Processing TaskStatus = "processing"
	Finished   TaskStatus = "finished"
	Canceled   TaskStatus = "canceled"
)

Jump to

Keyboard shortcuts

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