queue

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeoutParam string = "Timeout"
)

Constants are commonly used by all the tasks through kwargs.

Variables

This section is empty.

Functions

func GetDuration

func GetDuration(key interface{}) (time.Duration, error)

GetDuration parses key parameter to time.Duration type

Types

type Bootstrapper

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

Bootstrapper implements bootstrap.Bootstrapper.

func (*Bootstrapper) Bootstrap

func (b *Bootstrapper) Bootstrap(context map[string]interface{}) error

Bootstrap initiates the queue.

type Config

type Config interface {

	// GetNumWorkers gets the number of background workers to initiate
	GetNumWorkers() int

	// GetWorkerWaitTime gets the worker wait time for a task to be available while polling
	// increasing this may slow down task execution while reducing it may consume a lot of CPU cycles
	GetWorkerWaitTimeMS() int

	// GetTaskValidDuration until which the task is valid from the creation
	GetTaskValidDuration() time.Duration
}

Config is an interface for queue specific configurations

type Server

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

Server represents the queue server currently implemented based on gocelery

func (*Server) EnqueueJob

func (qs *Server) EnqueueJob(taskName string, params map[string]interface{}) (TaskResult, error)

EnqueueJob enqueues a job on the queue server for the given taskTypeName

func (*Server) Name

func (qs *Server) Name() string

Name of the queue server

func (*Server) RegisterTaskType

func (qs *Server) RegisterTaskType(name string, task interface{})

RegisterTaskType registers a task type on the queue server

func (*Server) Start

func (qs *Server) Start(ctx context.Context, wg *sync.WaitGroup, startupErr chan<- error)

Start the queue server

type TaskQueuer

type TaskQueuer interface {
	EnqueueJob(taskTypeName string, params map[string]interface{}) (TaskResult, error)
}

TaskQueuer can be implemented by any queueing system

type TaskResult

type TaskResult interface {

	// Get the result within a timeout from the queue task execution
	Get(timeout time.Duration) (interface{}, error)
}

TaskResult represents a result from a queued task execution

type TaskType

type TaskType interface {

	// TaskTypeName of the task
	TaskTypeName() string
}

TaskType is a task to be queued in the centrifuge node to be completed asynchronously

Jump to

Keyboard shortcuts

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