fangtooth

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2019 License: MIT Imports: 11 Imported by: 0

README

Fangtooth

Fangtooth is a bootstrap for queue workers.

Installation

go get -u github.com/Kamva/fangtooth

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configurator

type Configurator func(*WorkerPool)

Configurator is a function that accept worker pool as parameter and change its configurable attributes.

type JobHandlerMap

type JobHandlerMap map[string]interface{}

JobHandlerMap is a map of job name and its handler function.

type PeriodicMap added in v0.2.0

type PeriodicMap map[string]string

PeriodicMap is a map of cron tab value and job name to run in.

type WorkerContext

type WorkerContext struct{}

WorkerContext is base worker context

func (*WorkerContext) CaptureError

func (w *WorkerContext) CaptureError(job *work.Job, next work.NextMiddlewareFunc) error

CaptureError is a middleware for reporting panics and error in workers.

func (*WorkerContext) Log

func (w *WorkerContext) Log(job *work.Job, next work.NextMiddlewareFunc) error

Log is middleware that log the currently being processed job.

type WorkerInterface

type WorkerInterface interface {
	Log(*work.Job, work.NextMiddlewareFunc) error
	CaptureError(*work.Job, work.NextMiddlewareFunc) error
	Self() interface{}
}

WorkerInterface is an interface for workers contexts.

type WorkerPool

type WorkerPool struct {
	ConcurrentProcess uint
	// contains filtered or unexported fields
}

WorkerPool is responsible for fetching jobs out from redis pool and dispatching them to workers.

func NewWorkerPool

func NewWorkerPool(worker WorkerInterface, namespace string, redisPool *redis.Pool, configurators ...Configurator) *WorkerPool

NewWorkerPool construct new instance worker pool.

func (*WorkerPool) Listen

func (p *WorkerPool) Listen(jobMap JobHandlerMap) *WorkerPool

Listen will listens for incoming job with specified job name and handle it with its handler function.

func (*WorkerPool) Middleware

func (p *WorkerPool) Middleware(m ...interface{}) *WorkerPool

Middleware will add given middleware to process pipeline.

func (*WorkerPool) Periodic added in v0.2.0

func (p *WorkerPool) Periodic(jobMap PeriodicMap) *WorkerPool

Periodic will periodically enqueue given jobs based on it cron tabs.

func (*WorkerPool) Run

func (p *WorkerPool) Run()

Run starts worker pool and starts processing jobs.

Jump to

Keyboard shortcuts

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