Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseNumberArgs ¶
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) 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 (*App) GetConnection ¶
func (app *App) GetConnection() Connectable
GetConnection returns connection object
func (*App) GetRegisteredTask ¶
GetRegisteredTask returns registered task by name
func (*App) RegisterTask ¶
RegisterTask registers a single task
func (*App) RegisterTasks ¶
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 ¶
InitWorker - Worker constructor