config

package
v0.2024.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDebounce = 15 * time.Second
View Source
const DefaultEmailBody = `` /* 1724-byte string literal not displayed */
View Source
const DefaultEmailSubject = "Smart Core Notification"

Variables

This section is empty.

Functions

This section is empty.

Types

type Destination

type Destination struct {
	Host     string `json:"host,omitempty"`
	Port     int    `json:"port,omitempty"`
	Username string `json:"username,omitempty"` // defaults to From.Address
	jsontypes.Password

	From string   `json:"from,omitempty"` // RFC 5322 address, the address part used for auth against Host
	To   []string `json:"to,omitempty"`   // RFC 5322 address

	MinInterval *jsontypes.Duration `json:"minInterval,omitempty"` // minimum time between emails, to avoid spamming

	SubjectTemplate jsontypes.String `json:"subjectTemplate,omitempty"`
	BodyTemplate    jsontypes.String `json:"bodyTemplate,omitempty"`

	Parsed *ParsedDestination `json:"-"`
}

func (Destination) Addr

func (d Destination) Addr() string

Addr returns the combination of Host and Port, taking defaults into account. Suitable for smtp.Dial.

func (Destination) Parse

func (d Destination) Parse() (*ParsedDestination, error)

func (Destination) ReadBodyTemplate

func (d Destination) ReadBodyTemplate() (*template.Template, error)

func (Destination) ReadSubjectTemplate

func (d Destination) ReadSubjectTemplate() (*template.Template, error)

type ParsedDestination

type ParsedDestination struct {
	Addr            string
	Username        string
	Password        string
	From            *mail.Address
	To              []*mail.Address
	SubjectTemplate *template.Template
	BodyTemplate    *template.Template
}

type Root

type Root struct {
	auto.Config
	// Configuration information for how to send the email.
	Destination Destination `json:"destination,omitempty"`
	// If true, all devices on the current node that implement Status will be monitored.
	// Additional sources may be defined via Sources.
	DiscoverSources bool `json:"discoverSources,omitempty"`
	// Name of the devices that implement Status trait and that are monitored.
	Sources []Source `json:"sources,omitempty"`
	// Delay querying the status of devices by this much, to allow them to boot up.
	DelayStart *jsontypes.Duration `json:"delayStart,omitempty"`
	// Default debounce time for all sources.
	Debounce *jsontypes.Duration `json:"debounce,omitempty"`
	// Device name prefixes to ignore.
	// Only used if DiscoverSources is true.
	IgnorePrefixes []string `json:"ignorePrefixes,omitempty"`
}

func ReadBytes

func ReadBytes(data []byte) (cfg Root, err error)

type Source

type Source struct {
	Name      string `json:"name,omitempty"`
	Title     string `json:"title,omitempty"`
	Floor     string `json:"floor,omitempty"`
	Zone      string `json:"zone,omitempty"`
	Subsystem string `json:"subsystem,omitempty"`

	// Don't send emails until after this time expires, reduces noise.
	Debounce *jsontypes.Duration `json:"debounce,omitempty"`
}

func (Source) DebounceOrDefault

func (s Source) DebounceOrDefault() time.Duration

Jump to

Keyboard shortcuts

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