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 API ¶ added in v0.73.0
type API interface {
SendMessage(ctx context.Context, params *sqs.SendMessageInput, optFns ...func(*sqs.Options)) (*sqs.SendMessageOutput, error)
}
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
Publisher is a wrapper with added distributed tracing capabilities.
Example ¶
customResolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) { if service == sqs.ServiceID && region == "eu-west-1" { return aws.Endpoint{ URL: "http://localhost:4576", SigningRegion: "eu-west-1", }, nil } // returning EndpointNotFoundError will allow the service to fallback to it's default resolution return aws.Endpoint{}, &aws.EndpointNotFoundError{} }) cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("eu-west-1"), config.WithEndpointResolverWithOptions(customResolver), ) if err != nil { log.Fatal(err) } api := sqs.NewFromConfig(cfg) 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:
Click to show internal directories.
Click to hide internal directories.