async

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetermineDecoder added in v0.2.0

func DetermineDecoder(contentType string) (encoding.DecodeRawFunc, error)

DetermineDecoder determines the decoder based on the content type.

Types

type Component added in v0.4.2

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

Component implementation of a async component.

func New added in v0.4.2

func New(name string, p ProcessorFunc, cf ConsumerFactory, oo ...OptionFunc) (*Component, error)

New returns a new async component. The default behavior is to return a error of failure. Use options to change the default behavior.

func (*Component) Info added in v0.6.0

func (c *Component) Info() map[string]interface{}

Info return information of the component.

func (*Component) Run added in v0.4.2

func (c *Component) Run(ctx context.Context) error

Run starts the consumer processing loop messages.

type Consumer added in v0.4.2

type Consumer interface {
	Consume(context.Context) (<-chan Message, <-chan error, error)
	Close() error
	Info() map[string]interface{}
}

Consumer interface which every specific consumer has to implement.

type ConsumerFactory added in v0.7.0

type ConsumerFactory interface {
	Create() (Consumer, error)
}

ConsumerFactory interface for creating consumers.

type FailStrategy added in v0.5.2

type FailStrategy int

FailStrategy type definition.

const (
	// NackExitStrategy does not acknowledge the message and exits the application on error.
	NackExitStrategy FailStrategy = 0
	// NackStrategy does not acknowledge the message, leaving it for reprocessing, and continues.
	NackStrategy FailStrategy = 1
	// AckStrategy acknowledges message and continues.
	AckStrategy FailStrategy = 2
)

func (FailStrategy) String added in v0.7.1

func (fs FailStrategy) String() string

type Message added in v0.2.0

type Message interface {
	Context() context.Context
	Decode(v interface{}) error
	Ack() error
	Nack() error
}

Message interface for defining messages that are handled by the async component.

type OptionFunc added in v0.5.2

type OptionFunc func(*Component) error

OptionFunc definition for configuring the component in a functional way.

func ConsumerRetry added in v0.7.0

func ConsumerRetry(retries int, retryWait time.Duration) OptionFunc

ConsumerRetry set's the parameters for the retry policy of the consumer.

func FailureStrategy added in v0.5.2

func FailureStrategy(fs FailStrategy) OptionFunc

FailureStrategy option for setting the strategy of handling failures in the async component.

type ProcessorFunc added in v0.3.1

type ProcessorFunc func(Message) error

ProcessorFunc definition of a async processor.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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