beat

package
v0.0.0-...-320d922 Latest Latest
Warning

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

Go to latest
Published: May 10, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

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

View Source
const (
	StopState   = 0
	ConfigState = 1
	SetupState  = 2
	RunState    = 3
)

Defaults for config variables which are not set

Variables

This section is empty.

Functions

func Run

func Run(name string, version string, bt Beater) error

Run initiates and runs a new beat object

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 NewBeat

func NewBeat(name string, version string, bt Beater) *Beat

NewBeat initiates a new beat object

func (*Beat) CommandLineSetup

func (beat *Beat) CommandLineSetup() (error, bool)

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) Exit

func (b *Beat) Exit()

Exit begins exiting the beat and initiating shutdown

func (*Beat) LoadConfig

func (b *Beat) LoadConfig() error

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

func (b *Beat) Run() error

Run calls the beater Setup and Run methods. In case of errors during the setup phase, it exits the process.

func (*Beat) Start

func (b *Beat) Start() error

Start starts the Beat by parsing and interpreting the command line flags, loading and parsing the configuration file, and running the Beat. This method blocks until the Beat exits. If an error occurs while initializing or running the Beat it will be returned.

func (*Beat) Stop

func (b *Beat) Stop()

Stop calls the beater Stop action. It can happen that this function is called more then once.

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.

Jump to

Keyboard shortcuts

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