queue

package
v0.0.0-...-0bbd730 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2018 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateQueueRecord

func GenerateQueueRecord(rnd *rand.Rand) (models.Record, error)

GenerateQueueRecord creates a new queue record

func NewRecord

func NewRecord(id uuid.UUID,
	messageID string,
	receipt models.Receipt,
	body []byte,
	receivedAt time.Time,
) models.Record

NewRecord is a default queue record implementation

func NewTransaction

func NewTransaction() models.Transaction

NewTransaction creates a very simplistic models transaction

Types

type Config

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

Config encapsulates the requirements for generating a Queue

func Build

func Build(opts ...Option) (*Config, error)

Build ingests configuration options to then yield a Config and return an error if it fails during setup.

type ConfigOption

type ConfigOption func(*RemoteConfig) error

ConfigOption defines a option for generating a RemoteConfig

func WithEC2Role

func WithEC2Role(ec2Role bool) ConfigOption

WithEC2Role adds an EC2Role option to the configuration

func WithID

func WithID(id string) ConfigOption

WithID adds an ID option to the configuration

func WithMaxNumberOfMessages

func WithMaxNumberOfMessages(numOfMessages int64) ConfigOption

WithMaxNumberOfMessages adds an MaxNumberOfMessages option to the configuration

func WithQueue

func WithQueue(queue string) ConfigOption

WithQueue adds an Queue option to the configuration

func WithRegion

func WithRegion(region string) ConfigOption

WithRegion adds an Region option to the configuration

func WithSecret

func WithSecret(secret string) ConfigOption

WithSecret adds an Secret option to the configuration

func WithToken

func WithToken(token string) ConfigOption

WithToken adds an Token option to the configuration

func WithVisibilityTimeout

func WithVisibilityTimeout(visibilityTimeout time.Duration) ConfigOption

WithVisibilityTimeout adds an VisibilityTimeout option to the configuration

type Option

type Option func(*Config) error

Option defines a option for generating a queue Config

func With

func With(name string) Option

With adds a type of queue to use for the configuration.

func WithConfig

func WithConfig(remoteConfig *RemoteConfig) Option

WithConfig adds a remote queue config to the configuration

type Queue

type Queue interface {
	// Enqueue a record
	Enqueue(models.Record) error

	// Dequeue a record from the channel
	Dequeue() ([]models.Record, error)

	// Commit a transaction containing the records, so that an ack can be sent
	Commit(models.Transaction) (Result, error)

	// Failed a transaction containing the records, so that potential retries can
	// be used.
	Failed(models.Transaction) (Result, error)
}

Queue represents a series of records The queue's underlying backing store is a constructed from a channel, so it blocks if no body dequeues any items.

func New

func New(config *Config, logger log.Logger) (queue Queue, err error)

New creates a queue from a configuration or returns error if on failure.

type RemoteConfig

type RemoteConfig struct {
	EC2Role             bool
	ID, Secret, Token   string
	Region, Queue       string
	MaxNumberOfMessages int64
	VisibilityTimeout   time.Duration
}

RemoteConfig creates a configuration to create a RemoteQueue.

func BuildConfig

func BuildConfig(opts ...ConfigOption) (*RemoteConfig, error)

BuildConfig ingests configuration options to then yield a RemoteConfig, and return an error if it fails during configuring.

type Result

type Result struct {
	Success, Failure int
}

Result returns the amount of successes and failures

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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