worker

package
v0.0.0-...-ad0ef51 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	Start()
	CancelRunningJobByTaskUUID(uuid string) bool
	HoldRunningJobByTaskUUID(uuid string, do func(job *Job)) bool
}

func NewWorker

func NewWorker(ctx context.Context, taskChan chan *Task, callbacks TaskCallbacksInterface) Interface

type Job

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

func (*Job) Log

func (j *Job) Log() []byte

type SafeBuffer

type SafeBuffer struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

SafeBuffer prevents possible conflicts when shared by goroutines. In the current version, locking is implemented for

- Write, which is used by logboek

- Bytes, which can be used to get the log of the running job

func NewSafeBuffer

func NewSafeBuffer() *SafeBuffer

func (*SafeBuffer) Bytes

func (b *SafeBuffer) Bytes() []byte

func (*SafeBuffer) Write

func (b *SafeBuffer) Write(p []byte) (n int, err error)

type Task

type Task struct {
	Context context.Context
	UUID    string
	Action  func(ctx context.Context) error
}

type TaskCallbacksInterface

type TaskCallbacksInterface interface {
	TaskStartedCallback(ctx context.Context, uuid string)
	TaskFailedCallback(ctx context.Context, uuid string, log []byte, err error)
	TaskSucceededCallback(ctx context.Context, uuid string, log []byte)
}

type Worker

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

func (*Worker) CancelRunningJobByTaskUUID

func (w *Worker) CancelRunningJobByTaskUUID(uuid string) bool

func (*Worker) HoldRunningJobByTaskUUID

func (w *Worker) HoldRunningJobByTaskUUID(uuid string, do func(job *Job)) bool

func (*Worker) Start

func (w *Worker) Start()

Jump to

Keyboard shortcuts

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