Documentation ¶
Overview ¶
Package local defines "Local" flavor, which combines logging with StatusCheck.
Index ¶
- Constants
- type ConfOpts
- type FlavorLocal
- func (f *FlavorLocal) InfraDeps(pluginName string, opts ...InfraDepsOpts) *PluginInfraDeps
- func (f *FlavorLocal) Inject() bool
- func (f *FlavorLocal) LogDeps(pluginName string) *PluginLogDeps
- func (f *FlavorLocal) LogRegistry() logging.Registry
- func (f *FlavorLocal) LoggerFor(pluginName string) logging.PluginLogger
- func (f *FlavorLocal) Plugins() []*core.NamedPlugin
- type InfraDepsOpts
- type PluginInfraDeps
- type PluginLogDeps
Constants ¶
const LogsFlag = "logs-config"
LogsFlag used as flag name (see implementation in declareFlags()) It is used to define default directory where config files reside. This flag name is calculated from the name of the plugin.
const LogsFlagDefault = "logs.conf"
LogsFlagDefault - default file name
const LogsFlagUsage = "Location of the configuration files; also set via 'LOGS_CONFIG' env variable."
LogsFlagUsage used as flag usage (see implementation in declareFlags())
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfOpts ¶ added in v1.0.4
type ConfOpts struct {
// contains filtered or unexported fields
}
ConfOpts is a structure that holds default value & usage for configuration flag
func WithConf ¶ added in v1.0.4
WithConf is a function to create option for InfraDeps() no need to pass opts (used for defining flag if it was not already defined), if so in this order: - default value - usage
func (*ConfOpts) InfraDepsOpts ¶ added in v1.0.4
func (*ConfOpts) InfraDepsOpts()
InfraDepsOpts method is maker to declare implementation of InfraDepsOpts interface
type FlavorLocal ¶
type FlavorLocal struct { Logs logmanager.Plugin //needs to be first plugin (it updates log level from config) ServiceLabel servicelabel.Plugin StatusCheck statuscheck.Plugin // contains filtered or unexported fields }
FlavorLocal glues together very minimal subset of cn-infra plugins that can be embedded inside different projects without running any agent specific server.
func (*FlavorLocal) InfraDeps ¶
func (f *FlavorLocal) InfraDeps(pluginName string, opts ...InfraDepsOpts) *PluginInfraDeps
InfraDeps is a helper method for injecting PluginInfraDeps dependencies with plugins from the Local flavor. <pluginName> argument value is injected as the plugin name. Logging dependencies are resolved using the LogDeps() method. Plugin configuration file name is derived from the plugin name, see PluginConfig.GetConfigName(). This method is just a convenient shortcut to be used in Flavor.Inject() by flavors that embed the LocalFlavor..
func (*FlavorLocal) Inject ¶
func (f *FlavorLocal) Inject() bool
Inject injects logger into StatusCheck. Composite flavors embedding local flavor are supposed to call this method. Method returns <false> in case the injection has been already executed.
func (*FlavorLocal) LogDeps ¶
func (f *FlavorLocal) LogDeps(pluginName string) *PluginLogDeps
LogDeps is a helper method for injecting PluginLogDeps dependencies with plugins from the Local flavor. <pluginName> argument value is injected as the plugin name. Injected logger uses the same name as the plugin (see logging.ForPlugin) This method is just a convenient shortcut to be used in Flavor.Inject() by flavors that embed the LocalFlavor.
func (*FlavorLocal) LogRegistry ¶
func (f *FlavorLocal) LogRegistry() logging.Registry
LogRegistry for getting Logging Registry instance (not thread safe)
func (*FlavorLocal) LoggerFor ¶
func (f *FlavorLocal) LoggerFor(pluginName string) logging.PluginLogger
LoggerFor for getting PlugginLogger instance: - logger name is pre-initialized (see logging.ForPlugin) This method is just convenient shortcut for Flavor.Inject()
func (*FlavorLocal) Plugins ¶
func (f *FlavorLocal) Plugins() []*core.NamedPlugin
Plugins combines all Plugins in flavor to the list
type InfraDepsOpts ¶ added in v1.0.4
type InfraDepsOpts interface {
// InfraDepsOpts method is maker to declare implementation of InfraDepsOpts interface
InfraDepsOpts()
}
InfraDepsOpts is to make typesafe the InfraDeps varargs
type PluginInfraDeps ¶ added in v1.0.3
type PluginInfraDeps struct { PluginLogDeps // inject config.PluginConfig // inject StatusCheck statuscheck.PluginStatusWriter // inject ServiceLabel servicelabel.ReaderAPI // inject }
PluginInfraDeps is a standard set of plugin dependencies that will need probably every connector to DB/Messaging: - to report/write plugin status to StatusCheck - to know micro-service label prefix
type PluginLogDeps ¶ added in v1.0.3
type PluginLogDeps struct { Log logging.PluginLogger // inject PluginName core.PluginName // inject }
PluginLogDeps is minimal set of plugin dependencies that will probably use every plugin to:
- log messages using plugin logger or child (prefixed) logger (in case plugin needs more than one)
- to learn the plugin name
func (*PluginLogDeps) Close ¶ added in v1.0.3
func (plugin *PluginLogDeps) Close() error
Close is called by Agent Core when the Agent is shutting down. It is supposed to clean up resources that were allocated by the plugin during its lifetime. This is a default empty implementation used to not bother plugins that do not need to implement this method.