Import path:
gitlab.soludian.com/soludian/fountain/libs/brokers/providers/sns
sns
import "gitlab.soludian.com/soludian/fountain/libs/brokers/providers/sns"Index
- Constants
- Variables
- func AddOpts(opts []func(*sns.Options)) lib_3rd.Option[config]
- func WithAWSConfig(awsConfig aws.Config) lib_3rd.Option[config]
- func WithAccessKeyID(accessKey string) lib_3rd.Option[config]
- func WithConfig(conf *config) lib_3rd.Option[config]
- func WithCreateQueueConfig(conf SNSConfigAttributes) lib_3rd.Option[config]
- func WithEndPoint(endPoint string) lib_3rd.Option[config]
- func WithEnvironment(env string) lib_3rd.Option[config]
- func WithLogger(logger ...flog.FlogInf) lib_3rd.Option[config]
- func WithMarshaler(marshaler Marshaler) lib_3rd.Option[config]
- func WithName(name string) lib_3rd.Option[config]
- func WithOpts(opts []func(*sns.Options)) lib_3rd.Option[config]
- func WithRegion(region string) lib_3rd.Option[config]
- func WithSecretAccessKey(secret string) lib_3rd.Option[config]
- type Marshaler
- type MarshalerDefault
- type Publisher
- type SNSConfigAttributes
Constants
const KPackageName = "sns"const UUIDAttribute = "UUID"Variables
var GetFountainInstance = Lib.GetFountainInstancevar GetFountainManager = Lib.GetFountainManagerSử dụng khi config instance ở dạng key:value; Nếu config instance ở dạng key:array thì sử dụng hàm InstallFountainInstances Nếu config ở dạng key:array thì sẽ chỉ install config phần tử đầu tiên mà thôi
Install with config format <key>:<value>; eg: sns:<value>
Usage:
config.yaml:
sns:
name: default_name
...
code.go
sns.InstallFountainInstance()
sns.WithConfigKey("sns").InstallFountainInstance()var InstallFountainInstance = Lib.InstallFountainInstanceSử dụng khi config instance ở dạng key:array<value>; Sẽ luôn cố gắng khởi tạo kể cả khi config ở dạng key:value
Install with config format <key>:array<value>; eg: sns:array<value>
Usage:
config.yaml:
sns:
- name: default_name
...
code.go
sns.InstallFountainInstances()
sns.WithConfigKey("sns").InstallFountainInstances()var InstallFountainInstances = Lib.InstallFountainInstancesTruy cập thẳng tới bộ quản lý thư viện
var Lib = lib_3rd.NewLib(newClient, lib_3rd.WithDefaultConfigFunc[config, client](DefaultConfig))var WithConfigKey = Lib.WithConfigKeyfunc AddOpts
func AddOpts(opts []func(*sns.Options)) lib_3rd.Option[config]func WithAWSConfig
func WithAWSConfig(awsConfig aws.Config) lib_3rd.Option[config]func WithAccessKeyID
func WithAccessKeyID(accessKey string) lib_3rd.Option[config]func WithConfig
func WithConfig(conf *config) lib_3rd.Option[config]WithConfig
func WithCreateQueueConfig
func WithCreateQueueConfig(conf SNSConfigAttributes) lib_3rd.Option[config]func WithEndPoint
func WithEndPoint(endPoint string) lib_3rd.Option[config]func WithEnvironment
func WithEnvironment(env string) lib_3rd.Option[config]func WithLogger
func WithLogger(logger ...flog.FlogInf) lib_3rd.Option[config]func WithMarshaler
func WithMarshaler(marshaler Marshaler) lib_3rd.Option[config]func WithName
func WithName(name string) lib_3rd.Option[config]WithName
func WithOpts
func WithOpts(opts []func(*sns.Options)) lib_3rd.Option[config]func WithRegion
func WithRegion(region string) lib_3rd.Option[config]func WithSecretAccessKey
func WithSecretAccessKey(secret string) lib_3rd.Option[config]type Marshaler
type Marshaler interface {
Marshal(msg *brokers.Message) *sns.PublishInput
}type MarshalerDefault
type MarshalerDefault struct{}func (MarshalerDefault) Marshal
func (d MarshalerDefault) Marshal(msg *brokers.Message) *sns.PublishInputtype Publisher
type Publisher struct {
// contains filtered or unexported fields
}func (Publisher) AddSubscription
func (p Publisher) AddSubscription(topicName, sqsArn string) errorAddSubscription thêm một đăng ký (subscription) cho một chủ đề SNS (Simple Notification Service) với một hàng đợi SQS (Simple Queue Service).
Hàm này thực hiện các bước sau: 1. Tạo một context với timeout là 10 giây. 2. Lấy hoặc tạo một hàng đợi với tên chủ đề được cung cấp. 3. Liệt kê tất cả các đăng ký cho chủ đề SNS đã cho. 4. Kiểm tra xem có đăng ký nào đã tồn tại cho hàng đợi SQS với ARN (Amazon Resource Name) được cung cấp hay không. 5. Nếu không có đăng ký nào tồn tại, tạo một đăng ký mới với các thuộc tính cần thiết.
Tham số: - topicName: Tên của chủ đề SNS. - sqsArn: ARN của hàng đợi SQS.
Trả về: - error: Trả về lỗi nếu có bất kỳ bước nào thất bại, ngược lại trả về nil.
Usage:
err := publisher.AddSubscription("my-topic", "arn:aws:sqs:us-east-1:123456789012:my-queue")
if err != nil {
log.Fatalf("Failed to add subscription: %v", err)
}func (Publisher) Close
func (p Publisher) Close() errorfunc (Publisher) Publish
func (p Publisher) Publish(topic string, messages ...*brokers.Message) errortype SNSConfigAttributes
type SNSConfigAttributes struct {
DeliveryPolicy string `json:"DeliveryPolicy,omitempty"`
DisplayName string `json:"DisplayName,omitempty"`
Policy string `json:"Policy,omitempty"`
SignatureVersion string `json:"SignatureVersion,omitempty"`
TracingConfig string `json:"TracingConfig,omitempty"`
KmsMasterKeyId string `json:"KmsMasterKeyId,omitempty"`
FifoTopic string `json:"FifoTopic,omitempty"`
ContentBasedDeduplication string `json:"ContentBasedDeduplication,omitempty"`
}func (SNSConfigAttributes) Attributes
func (s SNSConfigAttributes) Attributes() map[string]stringGenerated by gomarkdoc