cfgfile

package
v5.6.16 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultReloadConfig = ReloadConfig{
		Reload: Reload{
			Period:  10 * time.Second,
			Enabled: false,
		},
	}
)

Functions

func ChangeDefaultCfgfileFlag

func ChangeDefaultCfgfileFlag(beatName string) error

ChangeDefaultCfgfileFlag replaces the value and default value for the `-c` flag so that it reflects the beat name.

func GetPathConfig added in v5.3.0

func GetPathConfig() string

GetPathConfig returns ${path.config}. If ${path.config} is not set, ${path.home} is returned.

func HandleFlags

func HandleFlags() error

HandleFlags adapts default config settings based on command line flags.

func IsTestConfig

func IsTestConfig() bool

IsTestConfig returns whether or not this is configuration used for testing

func Load

func Load(path string) (*common.Config, error)

Load reads the configuration from a YAML file structure. If path is empty this method reads from the configuration file specified by the '-c' command line flag.

func LoadList added in v5.3.0

func LoadList(file string) ([]*common.Config, error)

LoadList loads a list of configs data from the given file.

func Read deprecated

func Read(out interface{}, path string) error

Deprecated: Please use Load().

Read reads the configuration from a YAML file into the given interface structure. If path is empty this method reads from the configuration file specified by the '-c' command line flag.

Types

type GlobWatcher added in v5.3.0

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

func NewGlobWatcher added in v5.3.0

func NewGlobWatcher(glob string) *GlobWatcher

func (*GlobWatcher) Scan added in v5.3.0

func (gw *GlobWatcher) Scan() ([]string, bool, error)

Scan scans all files matched by the glob and checks if the number of files or the modtime of the files changed It returns the list of files, a boolean if anything in the glob changed and potential errors. To detect changes not only mod time is compared but also the hash of the files list. This is required to also detect files which were removed. The modtime is compared based on second as normally mod-time is in seconds. If it is unclear if something changed the method will return true for the changes. It is strongly recommend to call scan not more frequent then 1s.

type Registry added in v5.3.0

type Registry struct {
	sync.Mutex
	List map[uint64]Runner
}

func NewRegistry added in v5.3.0

func NewRegistry() *Registry

func (*Registry) Add added in v5.3.0

func (r *Registry) Add(hash uint64, m Runner)

func (*Registry) CopyList added in v5.3.0

func (r *Registry) CopyList() map[uint64]Runner

func (*Registry) Has added in v5.3.0

func (r *Registry) Has(hash uint64) bool

func (*Registry) Remove added in v5.3.0

func (r *Registry) Remove(hash uint64)

type Reload added in v5.3.0

type Reload struct {
	Period  time.Duration `config:"period"`
	Enabled bool          `config:"enabled"`
}

type ReloadConfig added in v5.3.0

type ReloadConfig struct {
	// If path is a relative path, it is relative to the ${path.config}
	Path   string `config:"path"`
	Reload Reload `config:"reload"`
}

type Reloader added in v5.3.0

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

Reloader is used to register and reload modules

func NewReloader added in v5.3.0

func NewReloader(cfg *common.Config) *Reloader

NewReloader creates new Reloader instance for the given config

func (*Reloader) Run added in v5.3.0

func (rl *Reloader) Run(runnerFactory RunnerFactory)

Run runs the reloader

func (*Reloader) Stop added in v5.3.0

func (rl *Reloader) Stop()

Stop stops the reloader and waits for all modules to properly stop

type Runner added in v5.3.0

type Runner interface {
	Start()
	Stop()
	ID() uint64
}

type RunnerFactory added in v5.3.0

type RunnerFactory interface {
	Create(*common.Config) (Runner, error)
}

Jump to

Keyboard shortcuts

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