Documentation
¶
Index ¶
- type AutostartConfig
- type Config
- type ConfigOption
- func AutostartDNS(s bool) ConfigOption
- func ConfigPath(p string) ConfigOption
- func ConfigType(t string) ConfigOption
- func DNSAddress(a string) ConfigOption
- func DNSFallback(f string) ConfigOption
- func DNSPrefix(p string) ConfigOption
- func DNSProto(p string) ConfigOption
- func DNSType(p string) ConfigOption
- func HTTPPort(p int) ConfigOption
- func HealthType(t string) ConfigOption
- func LoggerPath(p string) ConfigOption
- func LoggerType(t string) ConfigOption
- func StorePath(p string) ConfigOption
- func StoreType(t string) ConfigOption
- type DNSConfig
- type HTTPConfig
- type HealthConfig
- type LoggerConfig
- type StoreConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutostartConfig ¶
type AutostartConfig struct {
DNS bool `json:"dns,omitempty" yaml:"dns,omitempty"`
}
type Config ¶
type Config struct { DNS *DNSConfig `json:"dns,omitempty" yaml:"dns,omitempty"` Store *StoreConfig `json:"store,omitempty" yaml:"store,omitempty"` HTTP *HTTPConfig `json:"http,omitempty" yaml:"http,omitempty"` Logger *LoggerConfig `json:"logger,omitempty" yaml:"logger,omitempty"` Autostart *AutostartConfig `json:"autostart,omitempty" yaml:"autostart,omitempty"` Health *HealthConfig `json:"health,omitempty" yaml:"health,omitempty"` Type string `json:"type,omitempty" yaml:"type,omitempty"` Path string `json:"path,omitempty" yaml:"path,omitempty"` }
Config structures the setup of the DNS app, according to the caller's needs
This information can also be stored and loaded in a file for quicker access in future executions
func Default ¶
func Default() *Config
Default returns a pointer to a Config, initialized with sane defaults and ready for automatic start-up
func Merge ¶
Merge combines Configs `main` with `input`, returning a merged version of the two
All set elements in `input` will be applied to `main`, and the unset elements will be ignored (keeps `main`'s data)
func New ¶
func New(opts ...ConfigOption) *Config
New initializes a new config with default settings, and then iterates through all input ConfigOption `opts` applying them to the Config, which is returned to the caller
func (*Config) Apply ¶
func (c *Config) Apply(opts ...ConfigOption) *Config
Apply implements the ConfigOption interface
It allows applying new options on top of an already existing config
type ConfigOption ¶
type ConfigOption interface {
Apply(*Config)
}
ConfigOption describes setter types for a Config
As new options / elements are added to the Config, new data structures can implement the ConfigOption interface to allow setting these options in the Config
func AutostartDNS ¶
func AutostartDNS(s bool) ConfigOption
AutostartDNS creates a ConfigOption which will set the UDP server (DNS) to start listening when the app is executed (alongside the HTTP server), or to wait for a HTTP request against /dns/start
func ConfigPath ¶
func ConfigPath(p string) ConfigOption
ConfigPath creates a ConfigOption setting the Config's path to string `t`
It tries to call os.Stat() on string `p` to evaluate if the file exists. If it doesn't, it attempts to create it. If that fails too the returned ConfigOption is `nil`; otherwise it will return a ConfigOption to update the config path.
func ConfigType ¶
func ConfigType(t string) ConfigOption
ConfigType creates a ConfigOption setting the Config's type to string `t`
It defaults to `yaml`
func DNSAddress ¶
func DNSAddress(a string) ConfigOption
DNSAddress creates a ConfigOption setting the Config's DNS address to string `a`
It the string `a` is an invalid IP address, it returns `nil`
func DNSFallback ¶
func DNSFallback(f string) ConfigOption
DNSFallback creates a ConfigOption setting the Config's fallback DNS address(es) to string `f`
It the string `f` is empty, it returns `nil`
func DNSPrefix ¶
func DNSPrefix(p string) ConfigOption
DNSPrefix creates a ConfigOption setting the Config's DNS prefix to string `p`
It the string `p` is longer than one character, the first rune is converted to a string and that one is used.
DNS Prefix is a character inserted after a (simple, DNS store) domain which is required to perform the query, usually a dot (".")
E.g.: if you store "dns.example.com", a query for it would ask for "dns.example.com."
func DNSProto ¶
func DNSProto(p string) ConfigOption
DNSProto creates a ConfigOption setting the Config's DNS proto to string `p`
It defaults to `udp`
func DNSType ¶
func DNSType(p string) ConfigOption
DNSType creates a ConfigOption setting the Config's DNS type to string `t`
It defaults to `miekgdns`
func HTTPPort ¶
func HTTPPort(p int) ConfigOption
HTTPPort creates a ConfigOption setting the Config's HTTP port to int `p`
It returns nil if the input port `p` is 0 or over 65535, otherwise it will return a ConfigOption to update the HTTP port
func HealthType ¶
func HealthType(t string) ConfigOption
HealthType creates a ConfigOption setting the Config's health check type to string `t`
It defaults to `simplehealth`
func LoggerPath ¶
func LoggerPath(p string) ConfigOption
LoggerPath creates a ConfigOption setting the Config's logfile path to string `p`
It tries to call os.Stat() on string `p` to evaluate if the file exists. If it doesn't, it attempts to create it. If that fails too the returned ConfigOption is `nil`; otherwise it will return a ConfigOption to update the store path.
func LoggerType ¶
func LoggerType(t string) ConfigOption
LoggerType creates a ConfigOption setting the Config's logger type to string `t`
It defaults to `text`
func StorePath ¶
func StorePath(p string) ConfigOption
StorePath creates a ConfigOption setting the Config's store path to string `p`
It tries to call os.Stat() on string `p` to evaluate if the file exists. If it doesn't, it attempts to create it. If that fails too the returned ConfigOption is `nil`; otherwise it will return a ConfigOption to update the store path.
func StoreType ¶
func StoreType(t string) ConfigOption
StoreType creates a ConfigOption setting the Config's store type to string `t`
It defaults to `memmap`
type DNSConfig ¶
type DNSConfig struct { Type string `json:"type,omitempty" yaml:"type,omitempty"` FallbackDNS string `json:"fallback,omitempty" yaml:"fallback,omitempty"` Address string `json:"address,omitempty" yaml:"address,omitempty"` Prefix string `json:"prefix,omitempty" yaml:"prefix,omitempty"` Proto string `json:"proto,omitempty" yaml:"proto,omitempty"` }
type HTTPConfig ¶
type HTTPConfig struct {
Port int `json:"port,omitempty" yaml:"port,omitempty"`
}
type HealthConfig ¶
type HealthConfig struct {
Type string `json:"type,omitempty" yaml:"type,omitempty"`
}