userconfig

package
v0.0.0-...-c05b5d5 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Meta

type Meta struct {
	Scraping      Scraping         `yaml:"scraping"`
	EmailSettings email.UserConfig `yaml:"email"`
	LinkSources   []linksrc.Config `yaml:"link_sources"`
}

Meta represents all current config options that the application can use, i.e., after validation and parsing

func Parse

func Parse(r io.Reader) (*Meta, error)

Parse generates usable configurations from possibly arbitrary user input. An error indicates a problem with parsing or validation. The Reader r can be either JSON or YAML.

func (*Meta) CheckAndSetDefaults

func (m *Meta) CheckAndSetDefaults() (Meta, error)

CheckAndSetDefaults validates m and either returns a copy of m with default settings applied or returns an error due to an invalid configuration

type Scraping

type Scraping struct {
	Interval       time.Duration
	StorageDirPath string
	// Run the scraper once, then exit
	OneOff bool
	// Print the HTML body of a single email to stdout and exit to help test
	// configuration.
	TestMode bool
	// Number of days we keep a link in the database before marking it
	// expired.
	LinkExpiryDays uint
}

Scraping contains config options that apply to One Newsletter's scraping behavior

func (*Scraping) CheckAndSetDefaults

func (s *Scraping) CheckAndSetDefaults() (Scraping, error)

CheckAndSetDefaults validates s and either returns a copy of s with default settings applied or returns an error due to an invalid configuration

func (*Scraping) UnmarshalYAML

func (s *Scraping) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML parses a user-provided YAML configuration, returning any parsing errors.

Jump to

Keyboard shortcuts

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