Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorDatabase represents an error specific to database operations ErrorDatabase = errors.New("database error") // ErrorNotifier represents an error specific to notifier operations ErrorNotifier = errors.New("notifier error") // ErrorExecutor represents an error specific to the executor ErrorExecutor = errors.New("executor error") // ErrorFetch represents an error specific to address fetching operations ErrorFetch = errors.New("fetch error") )
Functions ¶
func InitLogger ¶
func InitLogger()
Types ¶
type Executor ¶
Executor is used to execute actions when an event is triggered. Needs an error channel to be passed, to be able to indicate when errors occur while executing the actions.
func NewExecutor ¶
NewExecutor creates a config.Exec executor.
Usage of a watcher.Executor
ex := NewExecutor(errorChannel)
action = config.Exec{
Type: "python",
Args: "",
Path: "script.py",
}
ex.Execute(action)
Each execution is associated with a context.ContextWithTimeout delimiting the maximum time the action has to execute, defined on the configuration file.
func (*Executor) Execute ¶
func (e *Executor) Execute(action config.ExecuteAction)
Execute executes the given config.Exec action defined on the configuration file under 'events.<event>.actions'. Runs the action with a timed out context.Context killing the process if a configuration file defined threshold (in seconds) is crossed, limiting the execution time of the action.
func (*Executor) ExecuteSlice ¶
func (e *Executor) ExecuteSlice(actions []config.ExecuteAction)
ExecuteSlice executes, in parallel, a slice of config.Exec actions.
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
func NewFetcher ¶
func NewFetcher() *Fetcher
type Notifier ¶
type Notifier struct {
// From is the address to send from, obtained from the configuration file at 'watcher.smtp.*'
From string
// Recipients is the slice containing the recipients information such as email and name
Recipients []Recipient
// contains filtered or unexported fields
}
Notifier allows for email mass notification
func NewNotifier ¶
func NewNotifier() *Notifier
type Recipient ¶
type Recipient struct {
// Name of the recipient
Name string `mapstructure:"name"`
// Address is the email address of the recipient
Address string `mapstructure:"address"`
}
Recipient represents a email recipient defined as per the configuration file
type Watcher ¶
type Watcher struct {
// Version indicates the versions the watcher is supposed to track (v4|v6|all)
Version string
// Timeout represents the duration between each address query
Timeout time.Duration
// contains filtered or unexported fields
}
Watcher is the main part of the IP watcher service. According to a defined timeout checks for address changes, invoking handlers to when different actions are triggered (on_change, on_match and on_error).
func NewWatcher ¶
func NewWatcher() *Watcher
NewWatcher creates a new watcher. Its parameters are set according to the values set on the YAML configuration file.