notifier

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config = &NotifierConfig{
	DSN:      "amqp://guest:guest@localhost:5672/",
	Exchange: "test",
}

Functions

This section is empty.

Types

type EmailSettings

type EmailSettings struct {
	Email    string      `json:"email"`
	Subject  string      `json:"subject"`
	Text     string      `json:"text,omitempty"`
	Template string      `json:"template,omitempty"`
	Data     interface{} `json:"data,omitempty"`
}

type MockPublisher

type MockPublisher struct {
	mock.Mock
}

func (*MockPublisher) Close

func (m *MockPublisher) Close() error

Close mocks the Close method of *rabbitmq.Channel.

func (*MockPublisher) PublishWithContext

func (m *MockPublisher) PublishWithContext(
	ctx context.Context,
	data []byte,
	routingKeys []string,
	optionFuncs ...func(options *rabbitmq.PublisherOptions)) error

Publish mocks the Publish method of *rabbitmq.Channel.

type NotificationPayload

type NotificationPayload struct {
	Type          string        `json:"type"`
	Data          interface{}   `json:"data"`
	EmailSettings EmailSettings `json:"email_setting,omitempty"`
	PhoneSettings PhoneSettings `json:"phone_setting,omitempty"`
	PushSettings  PushSettings  `json:"push_settings,omitempty"`
}

func NewNotification

func NewNotification(opts ...Option) NotificationPayload

type NotifierClient

type NotifierClient struct {
	// contains filtered or unexported fields
}

func NewNotifierClient

func NewNotifierClient(cfg *NotifierConfig) (*NotifierClient, error)

func (*NotifierClient) Close

func (n *NotifierClient) Close() error

func (*NotifierClient) Notify

func (n *NotifierClient) Notify(ctx context.Context, payload *NotificationPayload) error

type NotifierConfig

type NotifierConfig struct {
	DSN      string `json:"dsn"`
	Exchange string `json:"exchange"`
}

type Option

type Option func(o *options)

func WithData

func WithData(data interface{}) Option

func WithEmailSettings

func WithEmailSettings(s EmailSettings) Option

func WithPhoneSettings

func WithPhoneSettings(s PhoneSettings) Option

type PhoneSettings

type PhoneSettings struct {
	Phone    string      `json:"phone"`
	Text     string      `json:"text"`
	Template string      `json:"template,omitempty"`
	Data     interface{} `json:"data,omitempty"`
}

type PushSettings

type PushSettings struct {
	To       string      `json:"to"`              // Must be unique identifier for each user, for example user_id
	Image    string      `json:"image,omitempty"` // Must be valid direct link to image
	Title    string      `json:"title,omitempty"`
	Message  string      `json:"message,omitempty"`
	Template string      `json:"template,omitempty"`
	Data     interface{} `json:"data,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL