notifier

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Email   string `validate:"required"`
	Name    string `validate:"required"`
	Surname string `validate:"required"`
}

Address struct will be used to send the notification to the given Address.Email and also as the input for the message template

type AlertError

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

AlertError for errors which occurred during the alert send operation

func (AlertError) Error

func (ae AlertError) Error() string

Error

func (AlertError) Unwrap

func (ae AlertError) Unwrap() error

Unwrap can be used by the errors package to access the underlying error

type EmailClient

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

EmailClient struct implements the Notifier interface and can send alert and resolve notifications

func NewEmailClient

func NewEmailClient(config *EmailClientConfig, repo EmailReceiverRepository, logger *log.Logger) (*EmailClient, error)

NewEmailClient inits an EmailClient which can send e-mails for alert and resolve notifications

func (*EmailClient) Alert

func (e *EmailClient) Alert(ctx context.Context) error

Alert sends notification to the given receiver audience. Email Subject will contain the noun "alert" as prefix.

func (*EmailClient) Name

func (e *EmailClient) Name() string

Name gives the name of the email notifier

func (*EmailClient) Resolve

func (e *EmailClient) Resolve(ctx context.Context) error

Resolve sends notification to the given receiver audience. Email Subject will contain the adjective "resolved" as prefix.

type EmailClientConfig

type EmailClientConfig struct {
	Sender           EmailSender `validate:"required"`
	FromEmailAddress string      `validate:"required"`
}

EmailClientConfig struct holds all required parameters for the EmailClient

type EmailMessageBuildError

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

EmailMessageBuildError represents all messages that could not be built with the template and the given address input

func (EmailMessageBuildError) Error

func (e EmailMessageBuildError) Error() string

Error formats the EmailMessageBuildError to a nice error message

type EmailReceiver

type EmailReceiver struct {
	Name                   string    `validate:"required"`
	AlertSubject           string    `validate:"required"`
	ResolveSubject         string    `validate:"required"`
	AlertTemplateMessage   string    `validate:"required"`
	ResolveTemplateMessage string    `validate:"required"`
	Addresses              []Address `validate:"required,dive,required"`
}

EmailReceiver struct

type EmailReceiverRepository

type EmailReceiverRepository interface {
	GetEmailReceivers(ctx context.Context) ([]EmailReceiver, error)
}

type EmailSender

type EmailSender interface {
	DialAndSend(message ...*gomail.Message) error
}

EmailSender interface

type Notifier

type Notifier int

Notifier enum

const (
	// EmailNotifier enum for EmailClient
	EmailNotifier Notifier = iota
)

func (Notifier) String

func (n Notifier) String() string

String will return the name of the notifier

type ResolveError

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

ResolveError for errors which occurred during the alert send operation

func (ResolveError) Error

func (re ResolveError) Error() string

Error

func (ResolveError) Unwrap

func (re ResolveError) Unwrap() error

Unwrap can be used by the errors package to access the underlying error

Directories

Path Synopsis
Package mock_notifier is a generated GoMock package.
Package mock_notifier is a generated GoMock package.

Jump to

Keyboard shortcuts

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