machinery

package
v0.0.0-...-b386846 Latest Latest
Warning

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

Go to latest
Published: May 10, 2015 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseNumberArgs

func ParseNumberArgs(args []interface{}) ([]float64, error)

ParseNumberArgs - parses []interface{} into []float64

Types

type AMQPConnection

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

AMQPConnection represents an AMQP conenction (e.g. RabbitMQ)

func (AMQPConnection) Close

func (c AMQPConnection) Close() error

Close shuts down the connection

func (AMQPConnection) Open

func (c AMQPConnection) Open() (Connectable, error)

Open connects to the message queue, opens a channel, declares a queue and returns connection, channel and queue objects

func (AMQPConnection) PublishMessage

func (c AMQPConnection) PublishMessage(body []byte, routingKey string) error

PublishMessage places a new message on the default queue

func (AMQPConnection) WaitForMessages

func (c AMQPConnection) WaitForMessages(w *Worker)

WaitForMessages enters a loop and waits for incoming messages

type App

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

App is the main Machinery object and stores all configuration All the tasks workers process are registered against the app App.SendTask is one way of sending a task to workers

func InitApp

func InitApp(cnf *config.Config) (*App, error)

InitApp - App constructor

func (*App) GetConfig

func (app *App) GetConfig() *config.Config

GetConfig returns connection object

func (*App) GetConnection

func (app *App) GetConnection() Connectable

GetConnection returns connection object

func (*App) GetRegisteredTask

func (app *App) GetRegisteredTask(name string) Task

GetRegisteredTask returns registered task by name

func (*App) RegisterTask

func (app *App) RegisterTask(name string, task Task)

RegisterTask registers a single task

func (*App) RegisterTasks

func (app *App) RegisterTasks(tasks map[string]Task)

RegisterTasks registers all tasks at once

func (*App) SendTask

func (app *App) SendTask(s *TaskSignature) error

SendTask publishes a task to the default queue

type Connectable

type Connectable interface {
	Open() (Connectable, error)
	Close() error
	WaitForMessages(w *Worker)
	PublishMessage(body []byte, routingKey string) error
}

Connectable - a common interface for all connections

func ConnectionFactory

func ConnectionFactory(cnf *config.Config) (Connectable, error)

ConnectionFactory creates a new Connectable object Currently only AMQP is supported

func InitAMQPConnection

func InitAMQPConnection(cnf *config.Config) Connectable

InitAMQPConnection - AMQPConnection constructor

type Task

type Task interface {
	Run(args []interface{}) (interface{}, error)
}

Task is a common interface all registered tasks must implement

type TaskSignature

type TaskSignature struct {
	Name, RoutingKey string
	Args             []interface{}
	Immutable        bool
	OnSuccess        []*TaskSignature
	OnError          []*TaskSignature
}

TaskSignature represents a single task invocation

func Chain

func Chain(signatures ...TaskSignature) *TaskSignature

Chain - creates a chain of tasks to be executed one after another

type Worker

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

Worker represents a single worker process

func InitWorker

func InitWorker(app *App, consumerTag string) *Worker

InitWorker - Worker constructor

func (*Worker) Launch

func (w *Worker) Launch() error

Launch starts a new worker process The worker subscribes to the default queue and processes any incoming tasks registered against the app

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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