notifier

package module
v0.0.0-...-2975217 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: MIT Imports: 4 Imported by: 0

README

notifier

Mailer is wrapper for sendgrid api.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigMailer

type ConfigMailer struct {
	From     string
	NameFrom string
	Pass     string // Pass is sendgrid api key.

	MinRetryDelay time.Duration
	MaxRetryDelay time.Duration
}

ConfigMailer - config structure for sending email.

type ExpDelay

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

ExpDelay implements exponential delay and provides a convenient way to exponential delay..

func NewExpDelay

func NewExpDelay(min, max time.Duration) *ExpDelay

New returns new exponential delay which start with min delay, increase each next delay in 2 times up to max delay.

for delay := expdelay.New(minDelay, maxDelay); ; delay.Sleep() {
	err := op()
	if err == nil {
		break
	}
}

func (*ExpDelay) Sleep

func (d *ExpDelay) Sleep()

Sleep will call time.Sleep using current delay.

type Mail

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

Mail contains mail struct.

type Mailer

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

Mailer - struct with config and methods for sending emails. Wrapping the sendgrid api

func NewMailer

func NewMailer(log *structlog.Logger, config ConfigMailer) *Mailer

NewMailer - create new instance Mailer with checking the delays for correctness.

func (*Mailer) CreateEmail

func (m *Mailer) CreateEmail(to, subject, bodyMessage string) Mail

CreateEmail gets email props and returns prepared mail for SendEmail method.

func (*Mailer) SendEmail

func (m *Mailer) SendEmail(email string, mail Mail)

SendEmail sends mail to email and tries to send it until the email is sent or an error occurs.

Jump to

Keyboard shortcuts

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