Skip to content

Import path: gitlab.soludian.com/soludian/fountain/libs/brokers/providers/sns

sns

go
import "gitlab.soludian.com/soludian/fountain/libs/brokers/providers/sns"

Index

Constants

go
const KPackageName = "sns"

go
const UUIDAttribute = "UUID"

Variables

go
var GetFountainInstance = Lib.GetFountainInstance

go
var GetFountainManager = Lib.GetFountainManager

Sử 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()
go
var InstallFountainInstance = Lib.InstallFountainInstance

Sử 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()
go
var InstallFountainInstances = Lib.InstallFountainInstances

Truy cập thẳng tới bộ quản lý thư viện

go
var Lib = lib_3rd.NewLib(newClient, lib_3rd.WithDefaultConfigFunc[config, client](DefaultConfig))

go
var WithConfigKey = Lib.WithConfigKey

func AddOpts

go
func AddOpts(opts []func(*sns.Options)) lib_3rd.Option[config]

func WithAWSConfig

go
func WithAWSConfig(awsConfig aws.Config) lib_3rd.Option[config]

func WithAccessKeyID

go
func WithAccessKeyID(accessKey string) lib_3rd.Option[config]

func WithConfig

go
func WithConfig(conf *config) lib_3rd.Option[config]

WithConfig

func WithCreateQueueConfig

go
func WithCreateQueueConfig(conf SNSConfigAttributes) lib_3rd.Option[config]

func WithEndPoint

go
func WithEndPoint(endPoint string) lib_3rd.Option[config]

func WithEnvironment

go
func WithEnvironment(env string) lib_3rd.Option[config]

func WithLogger

go
func WithLogger(logger ...flog.FlogInf) lib_3rd.Option[config]

func WithMarshaler

go
func WithMarshaler(marshaler Marshaler) lib_3rd.Option[config]

func WithName

go
func WithName(name string) lib_3rd.Option[config]

WithName

func WithOpts

go
func WithOpts(opts []func(*sns.Options)) lib_3rd.Option[config]

func WithRegion

go
func WithRegion(region string) lib_3rd.Option[config]

func WithSecretAccessKey

go
func WithSecretAccessKey(secret string) lib_3rd.Option[config]

type Marshaler

go
type Marshaler interface {
    Marshal(msg *brokers.Message) *sns.PublishInput
}

type MarshalerDefault

go
type MarshalerDefault struct{}

func (MarshalerDefault) Marshal

go
func (d MarshalerDefault) Marshal(msg *brokers.Message) *sns.PublishInput

type Publisher

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

func (Publisher) AddSubscription

go
func (p Publisher) AddSubscription(topicName, sqsArn string) error

AddSubscription 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

go
func (p Publisher) Close() error

func (Publisher) Publish

go
func (p Publisher) Publish(topic string, messages ...*brokers.Message) error

type SNSConfigAttributes

go
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

go
func (s SNSConfigAttributes) Attributes() map[string]string

Generated by gomarkdoc