Documentation ¶
Overview ¶
Package awspubsub provides an implementation of pubsub that uses AWS SNS (Simple Notification Service) and SQS (Simple Queueing Service).
Escaping ¶
Go CDK supports all UTF-8 strings; to make this work with providers lacking full UTF-8 support, strings must be escaped (during writes) and unescaped (during reads). The following escapes are required for awspubsub:
- Metadata keys: Characters other than "a-zA-z0-9_-.", and additionally "." when it's at the start of the key or the previous character was ".", are escaped using "__0x<hex>__". These characters were determined by experimentation.
- Metadata values: Escaped using URL encoding.
- Message body: AWS SNS/SQS only supports UTF-8 strings. See the BodyBase64Encoding enum in TopicOptions for strategies on how to send non-UTF-8 message bodies. By default, non-UTF-8 message bodies are base64 encoded.
As ¶
awspubsub exposes the following types for As:
- Topic: *sns.SNS
- Subscription: *sqs.SQS
- Message: *sqs.Message
- Error: awserror.Error
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenSubscription ¶
func OpenSubscription(ctx context.Context, client *sqs.SQS, qURL string, opts *SubscriptionOptions) *pubsub.Subscription
OpenSubscription opens a on AWS SQS for the given SQS client and queue URL. The queue is assumed to be subscribed to some SNS topic, though there is no check for this.
Types ¶
type BodyBase64Encoding ¶ added in v0.11.0
type BodyBase64Encoding int
BodyBase64Encoding is an enum of strategies for when to base64 message bodies.
const ( // NonUTF8Only means that message bodies that are valid UTF-8 encodings are // sent as-is. Invalid UTF-8 message bodies are base64 encoded, and a // MessageAttribute with key "base64encoded" is added to the message. // When receiving messages, the "base64encoded" attribute is used to determine // whether to base64 decode, and is then filtered out. NonUTF8Only BodyBase64Encoding = 0 // Always means that all message bodies are base64 encoded. // A MessageAttribute with key "base64encoded" is added to the message. // When receiving messages, the "base64encoded" attribute is used to determine // whether to base64 decode, and is then filtered out. Always BodyBase64Encoding = 1 // Never means that message bodies are never base64 encoded. Non-UTF-8 // bytes in message bodies may be modified by SNS/SQS. Never BodyBase64Encoding = 2 )
type SubscriptionOptions ¶
type SubscriptionOptions struct{}
SubscriptionOptions will contain configuration for subscriptions.
type TopicOptions ¶
type TopicOptions struct { // BodyBase64Encoding determines when message bodies are base64 encoded. // The default is NonUTF8Only. BodyBase64Encoding BodyBase64Encoding }
TopicOptions contains configuration options for topics.