Documentation ¶
Overview ¶
Package beat provides the basic environment for each beat.
Each beat implementation has to implement the beater interface.
Start / Stop / Exit a Beat ¶
A beat is start by calling the Run(name string, version string, bt Beater) function and passing the beater object. This will create new beat and will Start the beat in its own go process. The Run function is blocked until the Beat.exit channel is closed. This can be done through calling Beat.Exit(). This happens for example when CTRL-C is pressed.
A beat can be stopped and started again through beat.Stop and beat.Start. When starting a beat again, it is important to run it again in it's own go process. To allow a beat to be properly reastarted, it is important that Beater.Stop() properly closes all channels and go processes.
In case a beat should not run as a long running process, the beater implementation must make sure to call Beat.Exit() when the task is completed to stop the beat.
Index ¶
Constants ¶
const ( StopState = 0 ConfigState = 1 SetupState = 2 RunState = 3 )
Defaults for config variables which are not set
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Beat ¶
type Beat struct { Name string Version string Config *BeatConfig BT Beater Publisher *publisher.PublisherType Events publisher.Client UUID uuid.UUID // contains filtered or unexported fields }
Beat struct contains the basic beat information
func (*Beat) CommandLineSetup ¶
CommandLineSetup reads and parses the default command line params To set additional cmd line args use the beat.CmdLine type before calling the function The second return param is to detect if system should exit. True if should exit Exit can also be without error
func (*Beat) LoadConfig ¶
LoadConfig inits the config file and reads the default config information into Beat.Config. It exists the processes in case of errors.
func (*Beat) Run ¶
Run calls the beater Setup and Run methods. In case of errors during the setup phase, it exits the process.
type BeatConfig ¶
type BeatConfig struct { Output map[string]*ucfg.Config Logging logp.Logging Shipper publisher.ShipperConfig }
BeatConfig struct contains the basic configuration of every beat
type Beater ¶
type Beater interface { Config(*Beat) error Setup(*Beat) error Run(*Beat) error Cleanup(*Beat) error Stop() }
Beater interface that every beat must use
type FlagsHandler ¶
type FlagsHandler interface {
HandleFlags(*Beat)
}
FlagsHandler (optional) Beater extension for handling flags input on startup. The HandleFlags callback will be called after parsing the command line arguments and handling the '--help' or '--version' flags.