local

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package local defines "Local" flavor, which combines logging with StatusCheck.

Index

Constants

View Source
const LogsFlagDefault = "logs.conf"

LogsFlagDefault - default file name

View Source
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

func NewAgent added in v1.0.7

func NewAgent(opts ...core.Option) *core.Agent

NewAgent returns a new instance of the Agent with plugins. It is an alias for core.NewAgent() to implicit use of the FlavorLocal.

Example:

   local.NewAgent(local.WithPlugins(func(flavor *FlavorLocal) {
	       return []*core.NamedPlugin{{"my-plugin", &MyPlugin{DependencyXY: &flavor.StatusCheck}}}
   }))

func WithPlugins added in v1.0.7

func WithPlugins(listPlugins func(local *FlavorLocal) []*core.NamedPlugin) core.WithPluginsOpt

WithPlugins for adding custom plugins to SFC Controller <listPlugins> is a callback that uses flavor input to inject dependencies for custom plugins that are in output.

Use this option either for core.NewAgent() or local.NewAgent()

Example:

   NewAgent(local.WithPlugins(func(flavor) {
	       return []*core.NamedPlugin{{"my-plugin", &MyPlugin{DependencyXY: &flavor.StatusCheck}}}
   }))

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

func WithConf(deafultUsageOpts ...string) *ConfOpts

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.

Jump to

Keyboard shortcuts

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