Package core - Core Burrow logic. The core package is where all the internal logic for Burrow is located. It provides several helpers for setting up logging and application management (such as PID files), as well as the Start method that runs Burrow itself.
The documentation for the rest of the internals, including all the available modules, is available at https://godoc.org/github.com/linkedin/Burrow/core/internal/?m=all. For the most part, end users of Burrow should not need to refer to this documentation, as it is targeted at developers of Burrow modules. Details on what modules are available and how to configure them are available at https://github.com/linkedin/Burrow/wiki
func CheckAndCreatePidFile ¶
CheckAndCreatePidFile takes a single argument, which is the path to a PID file (a file that contains a single integer, which is the process ID of a running process). If this file exists, and if the PID is that of a running process, return false as that indicates another copy of this process is already running. Otherwise, create the file and write this process's PID to the file and return true. Any error doing this (such as not having permissions to write the file) will return false.
This func should be called when Burrow starts to prevent multiple copies from running.
func ConfigureLogger ¶
func ConfigureLogger() (*zap.Logger, *zap.AtomicLevel)
ConfigureLogger returns a configured zap.Logger which can be used by Burrow for all logging. It also returns a zap.AtomicLevel, which can be used to dynamically adjust the level of the logger. The configuration for the logger is read from viper, with the following defaults:
logging.level = info
If logging.filename (path to the log file) is provided, a rolling log file is set up using lumberjack. The configuration for that log file is read from viper, with the following defaults:
logging.maxsize = 100 logging.maxbackups = 10 logging.maxage = 30 logging.use-localtime = false logging.use-compression = false
func OpenOutLog ¶
OpenOutLog takes a single argument, which is the path to a log file. This process's stdout and stderr are redirected to this log file. The os.File object is returned so that it can be managed.
func RemovePidFile ¶
func RemovePidFile(filename string)
RemovePidFile takes a single argument, which is the path to a PID file. That file is deleted. This func should be called when Burrow exits.
func Start(app *protocol.ApplicationContext, exitChannel chan os.Signal) int
Start is called to start the Burrow application. This is exposed so that it is possible to use Burrow as a library from within another application. Prior to calling this func, the configuration must have been loaded by viper from some underlying source (e.g. a TOML configuration file, or explicitly set in code after reading from another source). This func will block upon being called.
If the calling application would like to control logging, it can pass a pointer to an instantiated protocol.ApplicationContext struct that has the Logger and LogLevel fields set. Otherwise, Start will create a logger based on configurations in viper.
exitChannel is a signal channel that is provided by the calling application in order to signal Burrow to shut down. Burrow does not currently check the signal type: if any message is received on the channel, or if the channel is closed, Burrow will exit and Start will return 0.
Start will return a 1 on any failure, including invalid configurations or a failure to start Burrow modules.