cfgfile

package
v5.5.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: Apache-2.0 Imports: 12 Imported by: 2,548

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

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

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

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

func NewGlobWatcher

func NewGlobWatcher(glob string) *GlobWatcher

func (*GlobWatcher) Scan

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

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Add

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

func (*Registry) CopyList

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

func (*Registry) Has

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

func (*Registry) Remove

func (r *Registry) Remove(hash uint64)

type Reload

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

type ReloadConfig

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

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

Reloader is used to register and reload modules

func NewReloader

func NewReloader(cfg *common.Config) *Reloader

NewReloader creates new Reloader instance for the given config

func (*Reloader) Run

func (rl *Reloader) Run(runnerFactory RunnerFactory)

Run runs the reloader

func (*Reloader) Stop

func (rl *Reloader) Stop()

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

type Runner

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

type RunnerFactory

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