queue

package
v0.0.0-...-e360745 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	SagaID uuid.UUID `json:"saga_id"`
	Name   string    `json:"name"`
}

type Message

type Message interface {
	Command | Response
}

type Poll

type Poll[M Message] struct {
	// contains filtered or unexported fields
}

func NewPoll

func NewPoll[M Message](incoming *Receiver, target Processor, logger *zap.SugaredLogger) (Poll[M], error)

func (Poll[M]) Start

func (p Poll[M]) Start(ctx context.Context) error

Start polling the incoming queue and calls target's ProcessMessage method for each received message. The message is removed from the queue if the processing was successful. TODO Add concurrency calling ProcessMessage with limiting goroutines number.

type Processor

type Processor interface {
	ProcessMessage(context.Context, any) error
}

type Receiver

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

Receiver struct holds functionality to receive messages off of an SQS queue.

func NewReceiver

func NewReceiver(svc *sqs.SQS, name string, maxMessages, waitTime int64) (Receiver, error)

NewReceiver function returns a configured Receiver with sqs connection, queue name, config, and logger used.

func (Receiver) DeleteMessage

func (r Receiver) DeleteMessage(ctx context.Context, receiptHandle *string) error

DeleteMessage deletes a message with a receipt handle.

func (Receiver) ReceiveMessages

func (r Receiver) ReceiveMessages(ctx context.Context) ([]*sqs.Message, error)

ReceiveMessages returns slice of messages from the queue.

type Response

type Response struct {
	SagaID  uuid.UUID `json:"saga_id"`
	Service string    `json:"service"`
	Status  string    `json:"status"`
}

type Sender

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

Sender struct holds functionality to send notifications to an SQS queue.

func NewSender

func NewSender(q *sqs.SQS, queueName string) (*Sender, error)

NewSender returns a new Sender instance with SQS connection, queue name, logger, and notification store configured.

func (Sender) Send

func (s Sender) Send(msg interface{}) error

Send method sends a passed message to the queue.

Jump to

Keyboard shortcuts

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