reloader

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reloader

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

Reloader can watch config files and trigger reloads of a Prometheus server. It optionally substitutes environment variables in the configuration. Referenced environment variables must be of the form `$(var)` (not `$var` or `${var}`).

func New

func New(reloadURL *url.URL, cfgFile string, watchInterval time.Duration) *Reloader

New creates a new reloader that watches the given config file or directory and does HTTP POST.

func (*Reloader) Watch

func (r *Reloader) Watch(ctx context.Context) error

Watch starts to watch periodically the config file and rules and process them until the context gets canceled. Config file gets env expanded if cfgOutputFile is specified and reload is trigger if config or rules changed. Watch watchers periodically based on r.watchInterval. For config file it watches it directly as well via fsnotify. It watches rule dirs as well, but lot's of edge cases are missing, so rely on interval mostly.

func (*Reloader) WithWatchInterval

func (r *Reloader) WithWatchInterval(duration time.Duration)

We cannot detect everything via watch. Watch interval controls how often we re-read given dirs non-recursively.

Jump to

Keyboard shortcuts

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