Documentation ¶
Index ¶
- Variables
- type Agent
- type Option
- func AllPlugins(plugins ...infra.Plugin) Option
- func Context(ctx context.Context) Option
- func Plugins(plugins ...infra.Plugin) Option
- func QuitOnClose(ch chan struct{}) Option
- func QuitSignals(sigs ...os.Signal) Option
- func StartTimeout(timeout time.Duration) Option
- func StopTimeout(timeout time.Duration) Option
- func Version(buildVer, buildDate, commitHash string) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // BuildVersion describes version for the build. It is usually set using `git describe --always --tags --dirty`. BuildVersion = "v0.0.0-dev" // BuildDate describes time of the build. BuildDate string // CommitHash describes commit hash for the build. CommitHash string )
Variables set by the compiler using ldflags
View Source
var ( // DefaultStartTimeout is default timeout for starting agent DefaultStartTimeout = time.Second * 15 // DefaultStopTimeout is default timeout for stopping agent DefaultStopTimeout = time.Second * 5 // DumpStackTraceOnTimeout prints stack trace on timeout or agent start/stop DumpStackTraceOnTimeout = os.Getenv("DUMP_STACK_ON_TIMEOUT") != "" )
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface { // Run is a blocking call which starts the agent with all of its plugins, // waits for a signal from OS (SIGINT, SIGTERM by default), context cancellation or // close of quit channel (can be set via options) and then stops the agent. // Returns nil if all the plugins were intialized and closed successfully. Run() error // Start starts the agent with all the plugins, calling their Init() and optionally AfterInit(). // Returns nil if all the plugins were initialized successfully. Start() error // Stop stops the agent with all the plugins, calling their Close(). // Returns nil if all the plugins were closed successfully. Stop() error // Options returns all agent's options configured via constructor. Options() Options // Wait waits until agent is stopped and returns same error as Stop(). Wait() error // After returns a channel that is closed before the agents is stopped. // Note: It is not certain the all plugins are stopped, see Error().. After() <-chan struct{} // Error returns an error that occurret when the agent was stopped. // Note: This essentially just calls Stop().. Error() error }
Agent implements startup & shutdown procedures for plugins.
type Option ¶
type Option func(*Options)
Option is a function that operates on an Agent's Option
func AllPlugins ¶
AllPlugins creates an Option that adds all of the nested plugins recursively to the Agent's plugin list.
func QuitOnClose ¶
func QuitOnClose(ch chan struct{}) Option
QuitOnClose returns an Option that will set channel which stops Agent on close
func QuitSignals ¶
QuitSignals returns an Option that will set signals which stop Agent
func StartTimeout ¶
StartTimeout returns an Option that sets timeout for the start of Agent.
func StopTimeout ¶
StopTimeout returns an Option that sets timeout for the stop of Agent.
Click to show internal directories.
Click to hide internal directories.