Documentation
¶
Overview ¶
Package sns is doze-aws's ground-up, pure-Go SNS-compatible service: no LocalStack, no JVM. It speaks the SNS Query/XML protocol, persists topics and subscriptions to a bbolt store, supports message-attribute filter policies, raw message delivery, and topic tags, and fans published messages out to SQS queues (via the peers directory) and to http(s) webhooks with the subscription-confirmation handshake.
See docs/api-support/sns.md for the operation-by-operation support table.
Index ¶
- func MatchPolicy(policyJSON string, attrs map[string]string) bool
- type Attr
- type Options
- type Server
- type Store
- func (s *Store) ConfirmByToken(token string) (*Subscription, error)
- func (s *Store) CreateTopic(name string, attrs, tags map[string]string) (*Topic, error)
- func (s *Store) DeleteTopic(arn string) error
- func (s *Store) GetSubscription(arn string) (*Subscription, error)
- func (s *Store) GetTopic(arn string) (*Topic, error)
- func (s *Store) ListSubscriptions(topicFilter string) ([]Subscription, error)
- func (s *Store) ListTopics() ([]Topic, error)
- func (s *Store) SetSubscriptionAttribute(arn, name, value string) error
- func (s *Store) Subscribe(topicARN, protocol, endpoint string, attrs map[string]string) (*Subscription, error)
- func (s *Store) TopicExists(arn string) bool
- func (s *Store) Unsubscribe(arn string) error
- func (s *Store) UpdateTopic(arn string, fn func(*Topic)) error
- type Subscription
- type Topic
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchPolicy ¶
MatchPolicy reports whether a message carrying the given string attributes would satisfy a subscription's filter policy. Exported so the admin/CLI can show per-subscription routing without re-implementing the matcher. An empty policy matches everything.
Types ¶
type Attr ¶
type Attr = awsquery.MessageAttr
Attr is an SNS message attribute (String/Number use StringValue; Binary uses BinaryValue) — the Query codec's decoded shape, used directly.
type Options ¶
type Options struct {
// DataDir holds the bbolt store (sns.bolt). Required.
DataDir string
// Peers resolves sibling services; SQS-protocol subscriptions deliver
// through it. Nil disables SQS delivery (with a log line per attempt).
Peers peers.Directory
// Logf receives log lines; nil discards.
Logf func(format string, args ...any)
// Clock overrides time.Now in tests.
Clock func() time.Time
}
Options configures the service.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the SNS service: an http.Handler speaking the Query/XML protocol, and an io.Closer that closes the store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the bbolt-backed SNS state.
func (*Store) ConfirmByToken ¶
func (s *Store) ConfirmByToken(token string) (*Subscription, error)
ConfirmByToken confirms a pending http(s) subscription given its token.
func (*Store) CreateTopic ¶
func (*Store) DeleteTopic ¶
func (*Store) GetSubscription ¶
func (s *Store) GetSubscription(arn string) (*Subscription, error)
GetSubscription returns one subscription by ARN.
func (*Store) ListSubscriptions ¶
func (s *Store) ListSubscriptions(topicFilter string) ([]Subscription, error)
func (*Store) ListTopics ¶
func (*Store) SetSubscriptionAttribute ¶
func (*Store) Subscribe ¶
func (s *Store) Subscribe(topicARN, protocol, endpoint string, attrs map[string]string) (*Subscription, error)
Subscribe creates a subscription. SQS subscriptions are auto-confirmed; http(s) ones start pending with a confirmation token until ConfirmSubscription.
func (*Store) TopicExists ¶
TopicExists reports whether a topic ARN is known.
func (*Store) Unsubscribe ¶
type Subscription ¶
type Subscription struct {
ARN string `json:"arn"`
TopicARN string `json:"topic_arn"`
Protocol string `json:"protocol"` // sqs | http | https
Endpoint string `json:"endpoint"` // queue ARN/URL, or webhook URL
RawDelivery bool `json:"raw_delivery"`
FilterPolicy string `json:"filter_policy,omitempty"` // JSON
Confirmed bool `json:"confirmed"`
Token string `json:"token,omitempty"` // pending-confirmation token
// Extra round-trips subscription attributes with no local behavior
// (FilterPolicyScope, RedrivePolicy, DeliveryPolicy, ...).
Extra map[string]string `json:"extra,omitempty"`
}
Subscription is one subscription to a topic.
type Topic ¶
type Topic struct {
ARN string `json:"arn"`
Name string `json:"name"`
// Attrs round-trips SetTopicAttributes/CreateTopic attributes
// (DisplayName, Policy, ...). Locally most have no behavior; they are
// stored and returned faithfully.
Attrs map[string]string `json:"attrs,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
// DataProtectionPolicy round-trips Put/GetDataProtectionPolicy.
DataProtectionPolicy string `json:"data_protection_policy,omitempty"`
}
Topic is a declared/created SNS topic.