worker

package
v0.0.0-...-a8e29d9 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MaxNumberOfMessage at one poll
	MaxNumberOfMessage int64 = 10
	// WaitTimeSecond for each poll
	WaitTimeSecond int64 = 20
)

Exported variables

Functions

This section is empty.

Types

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 is used for the actual execution of each message

type InvalidMessageError

type InvalidMessageError struct {
	SQSMessage string
	LogMessage string
}

InvalidMessageError for message that can't be processed and should be deleted

func NewInvalidMessageError

func NewInvalidMessageError(SQSMessage, logMessage string) InvalidMessageError

NewInvalidMessageError to create new error for messages that should be deleted

func (InvalidMessageError) Error

func (e InvalidMessageError) Error() string

type Service

type Service struct {
	AWSSession         *session.Session
	BackupFirehose     *firehose.Firehose
	BackupFirehoseName string
	JobSQS             *sqs.SQS
	JobSQSURL          string
}

Service works through the job SQS queue

func NewService

func NewService(n string) (*Service, error)

NewService creates new worker service

func NewServiceWithConfig

func NewServiceWithConfig(n string, config aws.Config) (*Service, error)

NewServiceWithConfig creates a new worker service with the specified AWS config

func (*Service) Backup

func (s *Service) Backup(n string) *Service

Backup to set up Firehose backup option

func (*Service) Start

func (s *Service) Start(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