sqs

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

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

Broker run jobs using Broker service.

func (*Broker) Init

func (b *Broker) Init(cfg *Config) (bool, error)

Init configures local job broker.

func (*Broker) Listen

func (b *Broker) Listen(pipelines []*jobs.Pipeline, pool chan jobs.Handler, err jobs.ErrorHandler) error

Listen configures broker with list of tubes to listen and handler function. Local broker groups all tubes together.

func (*Broker) Push

func (b *Broker) Push(p *jobs.Pipeline, j *jobs.Job) (string, error)

Push new job to queue

func (*Broker) Serve

func (b *Broker) Serve() (err error)

Serve tubes.

func (*Broker) Stop

func (b *Broker) Stop()

Stop serving.

type Config

type Config struct {
	// Region defined SQS region, not required when endpoint is not empty.
	Region string

	// Region defined AWS API key, not required when endpoint is not empty.
	Key string

	// Region defined AWS API secret, not required when endpoint is not empty.
	Secret string

	// Endpoint can be used to re-define SQS endpoint to custom location. Only for local development.
	Endpoint string
}

Config defines sqs broker configuration.

func (*Config) Hydrate

func (c *Config) Hydrate(cfg service.Config) error

Hydrate config values.

func (*Config) SQS

func (c *Config) SQS() (*sqs.SQS, error)

SQS returns new SQS instance or error.

func (*Config) Session

func (c *Config) Session() (*session.Session, error)

Session returns new AWS session.

type Queue

type Queue struct {
	// Indicates that tube must be listened.
	Listen bool

	// Queue is queue name.
	Queue string

	// URL is queue url.
	URL *string

	// Create indicates that queue must be automatically created.
	Create bool

	// Attributes defines set of options to be used to create queue.
	Attributes map[interface{}]interface{}

	// Reserve - The duration (in seconds) that the received messages are hidden from subsequent. Default 600.
	Timeout int

	// WaitTime defines the number of seconds queue waits for job to arrive. Default 1.
	WaitTime int
}

Queue defines single SQS queue.

func NewQueue

func NewQueue(p *jobs.Pipeline) (*Queue, error)

NewTube creates new tube or returns an error

func (*Queue) CreateAttributes

func (q *Queue) CreateAttributes() (attr map[string]*string)

CreateAttributes must return queue create attributes.

Jump to

Keyboard shortcuts

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