executor

package
v0.0.0-...-37eefcc Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJobNotFound = errors.New("job not found")
	ErrToLate      = errors.New("too late")
)

Functions

func StartExecutionPool

func StartExecutionPool(ctx context.Context, dispatchQueue DispatchQueue, options ExecutorOptions)

StartExecutionPool starts executor pool, it can be closed by cancelling the passed context This needs to be run in a seperate go-routine

Types

type DispatchQueue

type DispatchQueue interface {
	// Next, returns next dispatched job
	// It won't block if dispatch queue is empty
	// Returns true if job is populated in given pointer
	Next(*jm.Job) bool
}

type Executor

type Executor interface {

	// Run adds the job to the execution queue.
	// Internally it is added in a time.After function
	Run(job jm.Job) error

	// Update updates the job details after the job is queued.
	// If the job is not queued, it will return ErrJobNotFound
	Update(job jm.Job) error

	// Delete deletes the queued job.
	// If the job is not queued, it will return ErrJobNotFound
	Delete(jobID string) error

	DispatchQueue
}

Executor queues the jobs and runs them one by one. It also includes methods to delete or update the job so that you can change the job state when it is queued in the memory.

func NewExecutor

func NewExecutor() Executor

type ExecutorOptions

type ExecutorOptions struct {
	RequestTimeout  time.Duration
	IdleConnTimeout time.Duration
	// Go-Routine pool size
	PoolSize int
}

Jump to

Keyboard shortcuts

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