brokers

package
v0.0.0-...-d2939e2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2016 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AMQPBroker

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

AMQPBroker represents an AMQP broker

func (*AMQPBroker) GetPendingTasks

func (amqpBroker *AMQPBroker) GetPendingTasks(queue string) ([]*signatures.TaskSignature, error)

GetPendingTasks returns a slice of task.Signatures waiting in the queue

func (*AMQPBroker) IsTaskRegistered

func (amqpBroker *AMQPBroker) IsTaskRegistered(name string) bool

IsTaskRegistered returns true if the task is registered with this broker

func (*AMQPBroker) Publish

func (amqpBroker *AMQPBroker) Publish(signature *signatures.TaskSignature) error

Publish places a new message on the default queue

func (*AMQPBroker) SetRegisteredTaskNames

func (amqpBroker *AMQPBroker) SetRegisteredTaskNames(names []string)

SetRegisteredTaskNames sets registered task names

func (*AMQPBroker) StartConsuming

func (amqpBroker *AMQPBroker) StartConsuming(consumerTag string, taskProcessor TaskProcessor) (bool, error)

StartConsuming enters a loop and waits for incoming messages

func (*AMQPBroker) StopConsuming

func (amqpBroker *AMQPBroker) StopConsuming()

StopConsuming quits the loop

type Broker

type Broker interface {
	SetRegisteredTaskNames(names []string)
	IsTaskRegistered(name string) bool
	StartConsuming(consumerTag string, p TaskProcessor) (bool, error)
	StopConsuming()
	Publish(task *signatures.TaskSignature) error
	GetPendingTasks(queue string) ([]*signatures.TaskSignature, error)
}

Broker - a common interface for all brokers

func NewAMQPBroker

func NewAMQPBroker(cnf *config.Config) Broker

NewAMQPBroker creates new AMQPBroker instance

func NewEagerBroker

func NewEagerBroker() Broker

NewEagerBroker creates new EagerBroker instance

func NewRedisBroker

func NewRedisBroker(cnf *config.Config, host, password, socketPath string, db int) Broker

NewRedisBroker creates new RedisBroker instance

type EagerBroker

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

EagerBroker represents an "eager" in-memory broker

func (*EagerBroker) AssignWorker

func (eagerBroker *EagerBroker) AssignWorker(w TaskProcessor)

AssignWorker assigns a worker to the eager broker

func (*EagerBroker) GetPendingTasks

func (eagerBroker *EagerBroker) GetPendingTasks(queue string) ([]*signatures.TaskSignature, error)

GetPendingTasks returns a slice of task.Signatures waiting in the queue

func (*EagerBroker) IsTaskRegistered

func (eagerBroker *EagerBroker) IsTaskRegistered(name string) bool

IsTaskRegistered returns true if the task is registered with this broker

func (*EagerBroker) Publish

func (eagerBroker *EagerBroker) Publish(task *signatures.TaskSignature) error

Publish places a new message on the default queue

func (*EagerBroker) SetRegisteredTaskNames

func (eagerBroker *EagerBroker) SetRegisteredTaskNames(names []string)

SetRegisteredTaskNames sets registered task names

func (*EagerBroker) StartConsuming

func (eagerBroker *EagerBroker) StartConsuming(consumerTag string, p TaskProcessor) (bool, error)

StartConsuming enters a loop and waits for incoming messages

func (*EagerBroker) StopConsuming

func (eagerBroker *EagerBroker) StopConsuming()

StopConsuming quits the loop

type EagerMode

type EagerMode interface {
	AssignWorker(p TaskProcessor)
}

EagerMode interface with methods specific for this broker

type RedisBroker

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

RedisBroker represents a Redis broker

func (*RedisBroker) GetPendingTasks

func (redisBroker *RedisBroker) GetPendingTasks(queue string) ([]*signatures.TaskSignature, error)

GetPendingTasks returns a slice of task.Signatures waiting in the queue

func (*RedisBroker) IsTaskRegistered

func (redisBroker *RedisBroker) IsTaskRegistered(name string) bool

IsTaskRegistered returns true if the task is registered with this broker

func (*RedisBroker) Publish

func (redisBroker *RedisBroker) Publish(signature *signatures.TaskSignature) error

Publish places a new message on the default queue

func (*RedisBroker) SetRegisteredTaskNames

func (redisBroker *RedisBroker) SetRegisteredTaskNames(names []string)

SetRegisteredTaskNames sets registered task names

func (*RedisBroker) StartConsuming

func (redisBroker *RedisBroker) StartConsuming(consumerTag string, taskProcessor TaskProcessor) (bool, error)

StartConsuming enters a loop and waits for incoming messages

func (*RedisBroker) StopConsuming

func (redisBroker *RedisBroker) StopConsuming()

StopConsuming quits the loop

type TaskProcessor

type TaskProcessor interface {
	Process(signature *signatures.TaskSignature) error
}

TaskProcessor - can process a delivered task This will probably always be a worker instance

Jump to

Keyboard shortcuts

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