loggerdelivery

package
v0.0.0-...-c7c8722 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DeliveryType = "mock"
View Source
var Factory = func(loader func(interface{}) error) (notificationdelivery.DeliveryDriver, error) {
	c := &Config{}
	err := loader(c)
	if err != nil {
		return nil, err
	}
	l := logger.GetBuiltinLogger(c.Logger)
	if l == nil {
		return nil, fmt.Errorf("builtin logger [%s] not found", c.Logger)
	}
	d := &Delivery{
		logger:       l,
		failPercent:  c.FailPercent,
		errorPercent: c.ErrorPercent,
	}
	if c.DelayMinDuration != "" {
		dmin, err := time.ParseDuration(c.DelayMinDuration)
		if err != nil {
			return nil, err
		}
		d.delayMin = dmin
	}
	if c.DelayMaxDuration != "" {
		dmax, err := time.ParseDuration(c.DelayMaxDuration)
		if err != nil {
			return nil, err
		}
		d.delayMax = dmax
	}
	if d.delayMax < d.delayMin {
		d.delayMax = d.delayMin
	}
	return d, nil
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Logger           string
	DelayMinDuration string
	DelayMaxDuration string
	FailPercent      int
	ErrorPercent     int
}

type Delivery

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

func (*Delivery) CheckInvalidContent

func (d *Delivery) CheckInvalidContent(notification.Content) ([]string, error)

CheckInvalidContent check if given content invalid Return invalid fields and any error raised

func (Delivery) ContentFields

func (d Delivery) ContentFields() []*notificationdelivery.Field

ContentFields return content fields Return invalid fields and any error raised

func (*Delivery) DeliveryType

func (d *Delivery) DeliveryType() string

func (*Delivery) MustEscape

func (d *Delivery) MustEscape(unescaped string) string

Jump to

Keyboard shortcuts

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