worker

package
v3.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSqsClient

func CreateSqsClient(awsConfigs ...*aws.Config) sqsiface.SQSAPI

CreateSqsClient creates a client for SQS API

Types

type Config

type Config struct {
	MaxNumberOfMessage    int64
	QueueName             string
	QueueURL              string
	WaitTimeSecond        int64
	MessageAttributeNames []string
}

Config struct

type Handler

type Handler interface {
	HandleMessage(msg *sqs.Message) error
}

Handler interface

type HandlerFunc

type HandlerFunc func(msg *sqs.Message) error

HandlerFunc is used to define the Handler that is run on for each message

func (HandlerFunc) HandleMessage

func (f HandlerFunc) HandleMessage(msg *sqs.Message) error

HandleMessage wraps a function for handling sqs messages

type InvalidEventError

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

InvalidEventError struct

func NewInvalidEventError

func NewInvalidEventError(event, msg string) InvalidEventError

NewInvalidEventError creates InvalidEventError struct

func (InvalidEventError) Error

func (e InvalidEventError) Error() string

type LoggerIFace

type LoggerIFace interface {
	Debug(i ...interface{})
	Info(i ...interface{})
	Error(i ...interface{})
}

LoggerIFace interface

type Worker

type Worker struct {
	Config    *Config
	Log       LoggerIFace
	SqsClient sqsiface.SQSAPI
}

Worker struct

func New

func New(client sqsiface.SQSAPI, config *Config) *Worker

New sets up a new Worker

func (*Worker) Start

func (worker *Worker) Start(ctx context.Context, h Handler)

Start starts the polling and will continue polling till the application is forcibly stopped

Jump to

Keyboard shortcuts

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