local

package
v0.0.0-...-d0f0867 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2017 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

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

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

type ConfOpts struct {
	// contains filtered or unexported fields
}

ConfOpts is a structure that holds default value & usage for configuration flag

func WithConf

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

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

type InfraDepsOpts interface {
	// InfraDepsOpts method is maker to declare implementation of InfraDepsOpts interface
	InfraDepsOpts()
}

InfraDepsOpts is to make typesafe the InfraDeps varargs

type PluginInfraDeps

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

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

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