worker

package
v0.0.0-...-df48f48 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxNumberOfMessage int32
	QueueName          *string
	QueueURL           *string
	WaitTimeSecond     int32
}

Config struct

type HandlerFunc

type HandlerFunc func(msg types.Message) HandlerFuncResponse

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

type HandlerFuncResponse

type HandlerFuncResponse struct {
	Status            ResponseStatus
	VisibilityTimeout *int32
}

type Logger

type Logger struct {
}

func (*Logger) Debug

func (l *Logger) Debug(i ...interface{})

func (*Logger) Error

func (l *Logger) Error(i ...interface{})

func (*Logger) Info

func (l *Logger) Info(i ...interface{})

func (*Logger) Warn

func (l *Logger) Warn(i ...interface{})

type LoggerIFace

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

LoggerIFace interface

type ResponseStatus

type ResponseStatus string
const (
	KeepMessage             ResponseStatus = "KeepMessage"
	DeleteMessage           ResponseStatus = "DeleteMessage"
	ChangeMessageVisibility ResponseStatus = "ChangeMessageVisibility"
)

type SqsConsumeApi

type SqsConsumeApi interface {
	GetQueueUrl(ctx context.Context,
		params *sqs.GetQueueUrlInput,
		optFns ...func(*sqs.Options)) (*sqs.GetQueueUrlOutput, error)

	ReceiveMessage(ctx context.Context,
		params *sqs.ReceiveMessageInput,
		optFns ...func(*sqs.Options)) (*sqs.ReceiveMessageOutput, error)

	DeleteMessage(ctx context.Context,
		params *sqs.DeleteMessageInput,
		optFns ...func(*sqs.Options)) (*sqs.DeleteMessageOutput, error)

	ChangeMessageVisibility(ctx context.Context,
		params *sqs.ChangeMessageVisibilityInput,
		optFns ...func(*sqs.Options)) (*sqs.ChangeMessageVisibilityOutput, error)
}

func CreateSqsClient

func CreateSqsClient(awsConfig aws.Config) SqsConsumeApi

CreateSqsClient creates a client for SQS API

type Worker

type Worker struct {
	Config    *Config
	Log       LoggerIFace
	SqsClient SqsConsumeApi
}

Worker struct

func New

func New(client SqsConsumeApi, config *Config, logger LoggerIFace) *Worker

New sets up a new Worker

func (*Worker) Start

func (worker *Worker) Start(ctx context.Context, fn HandlerFunc)

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