worq

package module
v0.0.0-...-d4cb73b Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2018 License: MIT Imports: 7 Imported by: 0

README

go-work CircleCI GoDoc

A distributed task/job queue framework for Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

func New

func New(options ...OptionFunc) (*App, error)

func (*App) Binder

func (app *App) Binder() Binder

func (*App) Context

func (app *App) Context() Context

func (*App) Enqueue

func (app *App) Enqueue(sig *Signature) (*AsyncResult, error)

func (*App) Protocol

func (app *App) Protocol() Protocol

func (*App) Register

func (app *App) Register(name string, f TaskFunc) error

func (*App) Start

func (app *App) Start() error

type AsyncResult

type AsyncResult struct {
	ID string
}

type Binder

type Binder interface {
	Bind(ctx Context, v interface{}) error
	Unbind(ctx Context, id string, queue string, sig *Signature) (*Publishing, error)
}

type Broker

type Broker interface {
	Consume(ctx Context, queueName string) (Consumer, error)

	Close() error

	Enqueue(*Publishing) error
}

type Consumer

type Consumer interface {
	Next() bool
	Err() error
	Message() (Message, error)
	Close() error

	Ack(message Message) error
	Nack(message Message, requeue bool) error
}

type Context

type Context interface {
	App() *App

	Logger() logrus.FieldLogger

	Consumer() Consumer

	Message() Message

	Bind(v interface{}) error

	Reject(requeue bool) error

	Deadline() (deadline time.Time, ok bool)

	Done() <-chan struct{}

	Err() error

	Value(key interface{}) interface{}
}

type Message

type Message interface {
	Queue() string

	ID() string

	Task() string

	Headers() map[string]interface{}

	ContentType() string

	Body() []byte
}

type MockContext

type MockContext struct {
	MessageFactory func() Message
	// contains filtered or unexported fields
}

func NewMockContext

func NewMockContext() *MockContext

func (*MockContext) App

func (ctx *MockContext) App() *App

func (*MockContext) Bind

func (ctx *MockContext) Bind(v interface{}) error

func (*MockContext) Consumer

func (ctx *MockContext) Consumer() Consumer

func (*MockContext) Deadline

func (*MockContext) Deadline() (deadline time.Time, ok bool)

func (*MockContext) Done

func (*MockContext) Done() <-chan struct{}

func (*MockContext) Err

func (*MockContext) Err() error

func (*MockContext) Logger

func (ctx *MockContext) Logger() logrus.FieldLogger

func (*MockContext) Message

func (ctx *MockContext) Message() Message

func (*MockContext) Reject

func (ctx *MockContext) Reject(requeue bool) error

func (*MockContext) Value

func (*MockContext) Value(key interface{}) interface{}

type MockMessage

type MockMessage struct {
	MockQueue       string
	MockID          string
	MockTask        string
	MockHeaders     map[string]interface{}
	MockContentType string
	MockBody        []byte
}

func (*MockMessage) Body

func (msg *MockMessage) Body() []byte

func (*MockMessage) ContentType

func (msg *MockMessage) ContentType() string

func (*MockMessage) Headers

func (msg *MockMessage) Headers() map[string]interface{}

func (*MockMessage) ID

func (msg *MockMessage) ID() string

func (*MockMessage) Queue

func (msg *MockMessage) Queue() string

func (*MockMessage) Task

func (msg *MockMessage) Task() string

type OptionFunc

type OptionFunc func(*App) error

OptionFunc is a function that configures the App.

func SetBinder

func SetBinder(binder Binder) OptionFunc

func SetBroker

func SetBroker(broker Broker) OptionFunc

func SetConcurrency

func SetConcurrency(concurrency int) OptionFunc

func SetDefaultQueue

func SetDefaultQueue(queue string) OptionFunc

func SetLogger

func SetLogger(logger logrus.FieldLogger) OptionFunc

SetLogger sets the logger that the app will use.

func SetProtocol

func SetProtocol(protocol Protocol) OptionFunc

type Protocol

type Protocol interface {
	ID(message Message) (string, error)

	Task(message Message) (string, error)
}

type Publishing

type Publishing struct {
	ID          string
	Queue       string
	Headers     map[string]interface{}
	ContentType string
	Body        []byte
}

type Signature

type Signature struct {
	Task string
	Args interface{}
}

func NewSignature

func NewSignature(task string, args interface{}) *Signature

type TaskFunc

type TaskFunc func(ctx Context) error

type TaskNotFound

type TaskNotFound struct {
	Name string
}

func (TaskNotFound) Error

func (t TaskNotFound) Error() string

type TaskRejected

type TaskRejected struct {
	Requeue bool
}

func (TaskRejected) Error

func (t TaskRejected) Error() string

Directories

Path Synopsis
_examples
brokers
protocols

Jump to

Keyboard shortcuts

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