sqs

package
v0.62.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package sqs provides a set of common interfaces and structs for publishing messages to AWS SQS. Implementations in this package also include distributed tracing capabilities by default.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Publisher

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

Publisher is a wrapper with added distributed tracing capabilities.

Example
// Create the SQS API with the required config, credentials, etc.
sess, err := session.NewSession(
	aws.NewConfig().
		WithEndpoint("http://localhost:4576").
		WithRegion("eu-west-1").
		WithCredentials(
			credentials.NewStaticCredentials("aws-id", "aws-secret", "aws-token"),
		),
)
if err != nil {
	log.Fatal(err)
}

api := sqs.New(sess)

pub, err := New(api)
if err != nil {
	log.Fatal(err)
}

msg := &sqs.SendMessageInput{
	MessageBody: aws.String("message body"),
	QueueUrl:    aws.String("http://localhost:4576/queue/foo-queue"),
}

msgID, err := pub.Publish(context.Background(), msg)
if err != nil {
	log.Fatal(err)
}

fmt.Println(msgID)
Output:

func New

func New(api sqsiface.SQSAPI) (Publisher, error)

New creates a new SQS publisher.

func (Publisher) Publish

func (p Publisher) Publish(ctx context.Context, msg *sqs.SendMessageInput) (messageID string, err error)

Publish tries to publish a new message to SQS. It also stores tracing information.

Jump to

Keyboard shortcuts

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