alert

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPSender

func NewHTTPSender(client *http.Client, cfg alert.Config, url string) alert.Sender

NewHTTPSender returns a new alert.Sender

func NewHTTPSenderWithDefault

func NewHTTPSenderWithDefault(cfg alert.Config) alert.Sender

NewHTTPSenderWithDefault returns a new alert.Sender with default http client

func NewRepository

func NewRepository(db middleware.Pool) alert.Repository

NewRepository returns *Repository with given middleware.Pool

func NewRepositoryWithGlobal

func NewRepositoryWithGlobal() alert.Repository

NewRepositoryWithGlobal returns *Repository with global mysql pool

func NewSMTPSender

func NewSMTPSender(client *smtp.Client, cfg alert.Config, url string) alert.Sender

NewSMTPSender returns a new alert.Sender

func NewSMTPSenderWithDefault

func NewSMTPSenderWithDefault(cfg alert.Config) (alert.Sender, error)

NewSMTPSenderWithDefault returns a new alert.Sender with default SMTP client

func NewService

func NewService(repository alert.Repository, config alert.Config) alert.Service

NewService returns a new alert.Service

func NewServiceWithDefault

func NewServiceWithDefault(config alert.Config) alert.Service

NewServiceWithDefault returns a new alert.Service with default repository

Types

type Config

type Config map[string]string

func NewConfigFromFile

func NewConfigFromFile() Config

NewConfigFromFile returns a new Config which reads data from config file

func NewEmptyConfig

func NewEmptyConfig() Config

NewEmptyConfig returns a new empty Config

func (Config) Delete

func (c Config) Delete(key string)

Delete deletes the given key from the config

func (Config) Get

func (c Config) Get(key string) string

Get returns the value of the given key

func (Config) Set

func (c Config) Set(key string, value string)

Set sets the value of the given key

func (Config) String

func (c Config) String() string

String returns the string value of the config

type HTTPSender

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

func (*HTTPSender) GetClient

func (hs *HTTPSender) GetClient() *http.Client

GetClient returns the http client

func (*HTTPSender) GetConfig

func (hs *HTTPSender) GetConfig() alert.Config

GetConfig return the config

func (*HTTPSender) GetURL

func (hs *HTTPSender) GetURL() string

GetURL returns the http api url

func (*HTTPSender) Send

func (hs *HTTPSender) Send() error

Send sends the email via http api calling

type Repository

type Repository struct {
	Database middleware.Pool
}

func (*Repository) Execute

func (r *Repository) Execute(command string, args ...interface{}) (middleware.Result, error)

Execute executes given command and placeholders on the middleware

func (*Repository) Save

func (r *Repository) Save(url, toAddrs, ccAddrs, subject, content, config, message string) error

Save saves sending result into the middleware

func (*Repository) Transaction

func (r *Repository) Transaction() (middleware.Transaction, error)

Transaction returns a middleware.Transaction that could execute multiple commands as a transaction

type Response

type Response struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func NewEmptyResponse

func NewEmptyResponse() *Response

NewEmptyResponse returns a new empty *Response

func (*Response) GetCode

func (r *Response) GetCode() int

GetCode returns the code

func (*Response) GetMessage

func (r *Response) GetMessage() string

GetMessage returns the message

type SMTPSender

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

func (*SMTPSender) GetClient

func (ss *SMTPSender) GetClient() *smtp.Client

GetClient returns the smtp client

func (*SMTPSender) GetConfig

func (ss *SMTPSender) GetConfig() alert.Config

GetConfig returns the config

func (*SMTPSender) GetURL

func (ss *SMTPSender) GetURL() string

GetAddr returns the addr

func (*SMTPSender) Send

func (ss *SMTPSender) Send() error

Send sends the email via the api calling

type Service

type Service struct {
	alert.Repository
	// contains filtered or unexported fields
}

func (*Service) GetConfig

func (s *Service) GetConfig() alert.Config

GetConfig returns the config of the service

func (*Service) GetRepository

func (s *Service) GetRepository() alert.Repository

GetRepository returns the repository of the service

func (*Service) Save

func (s *Service) Save(toAddrs, ccAddrs, subject, content, message string) error

Save saves the email into the middleware

func (*Service) SendEmail

func (s *Service) SendEmail(toAddrs, ccAddrs, subject, content string) error

SendEmail sends the email

Jump to

Keyboard shortcuts

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