engine

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package engine provides functionality for creating and running an engine.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingConsumerQueue is returned when the consumer queue name is missing.
	ErrMissingConsumerQueue = errors.New("missing consumer queue name")
	// ErrMissingConsumerQueueURL is returned when the consumer queue url is missing.
	ErrMissingConsumerQueueURL = errors.New("missing consumer queue url")
	// ErrMissingProducerQueue is returned when the producer queue name is missing.
	ErrMissingProducerQueue = errors.New("missing producer queue name")
	// ErrMissingRegion is returned when the queue region is missing.
	ErrMissingRegion = errors.New("missing queue region")
)
View Source
var BackoffStrategy = func() backoff.BackOff {
	return &backoff.ExponentialBackOff{
		Clock:               backoff.SystemClock,
		InitialInterval:     5 * time.Second,
		MaxInterval:         10 * time.Second,
		MaxElapsedTime:      300 * time.Second,
		Multiplier:          backoff.DefaultMultiplier,
		RandomizationFactor: backoff.DefaultRandomizationFactor,
	}
}

BackoffStrategy is the backoff strategy used when attempting retryable errors.

View Source
var ErrHandler = func(ctx context.Context, event string, err error) {
	log.Event(ctx, event, log.ERROR, log.Error(err))
}

ErrHandler is the handler function applied to an error.

Functions

This section is empty.

Types

type Engine

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

Engine represents an engine.

func New

func New(cfg *config.Configuration, hs map[string]HandlerFunc) (*Engine, error)

New returns a new engine.

func (*Engine) Start

func (e *Engine) Start(ctx context.Context)

Start starts the queue consumer and applies a given handler function to each message that is consumed. Once the message has successfully been handled, we attempt to write the result of the handler function to an outbound queue. If the result is written successfully, the message that was originally consumed is removed from the queue.

type HandlerFunc

type HandlerFunc func(context.Context, *Message) error

HandlerFunc represents a function that is applied to a consumed message.

type InvalidBlockError

type InvalidBlockError struct {
	MessageID string
}

InvalidBlockError is an error implementation that includes a consumed message ID.

func (*InvalidBlockError) Error

func (e *InvalidBlockError) Error() string

type Message

type Message struct {
	Artifacts []string
	Bucket    string
	ID        string `json:"-"`
	Service   string
	Type      string
}

Message represents a message that has been consumed.

type MissingHandlerError

type MissingHandlerError struct {
	MessageType string
}

MissingHandlerError is an error implementation that includes a consumed message type.

func (*MissingHandlerError) Error

func (e *MissingHandlerError) Error() string

Jump to

Keyboard shortcuts

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