config

package
v0.0.0-...-7697303 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2017 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorReadConfigFile1     = errutil.NewFactory("Failed to read config file: %q")
	ErrorUnmarshalJSONConfig = errutil.NewFactory("Failed unmarshalling config in JSON format")
	ErrorUnmarshalYAMLConfig = errutil.NewFactory("Failed unmarshalling config in YAML format")
	ErrorTimeout1            = errutil.NewFactory("timeout: %v")
)

errors

View Source
var (
	ErrorUnknownFilterType1 = errutil.NewFactory("unknown filter config type: %q")
	ErrorInitFilterFailed1  = errutil.NewFactory("initialize filter module failed: %v")
)

errors

View Source
var (
	ErrorUnknownInputType1 = errutil.NewFactory("unknown input config type: %q")
	ErrorInitInputFailed1  = errutil.NewFactory("initialize input module failed: %v")
)

errors

View Source
var (
	ErrorUnknownOutputType1 = errutil.NewFactory("unknown output config type: %q")
	ErrorInitOutputFailed1  = errutil.NewFactory("initialize output module failed: %v")
)

errors

View Source
var (
	// Logger app logger
	Logger = logutil.DefaultLogger
)

Functions

func ReflectConfig

func ReflectConfig(confraw *ConfigRaw, conf interface{}) (err error)

ReflectConfig set conf from confraw

func RegistFilterHandler

func RegistFilterHandler(name string, handler FilterHandler)

RegistFilterHandler regist a filter handler

func RegistInputHandler

func RegistInputHandler(name string, handler InputHandler)

RegistInputHandler regist a input handler

func RegistOutputHandler

func RegistOutputHandler(name string, handler OutputHandler)

RegistOutputHandler regist a output handler

Types

type CommonConfig

type CommonConfig struct {
	Type string `json:"type"`
}

CommonConfig is basic config struct

func (CommonConfig) GetType

func (t CommonConfig) GetType() string

GetType return module type of config

type Config

type Config struct {
	InputRaw  []ConfigRaw `json:"input,omitempty" yaml:"input"`
	FilterRaw []ConfigRaw `json:"filter,omitempty" yaml:"filter"`
	OutputRaw []ConfigRaw `json:"output,omitempty" yaml:"output"`

	// channel size: chInFilter, chFilterOut, chOutDebug
	ChannelSize int `json:"chsize,omitempty" yaml:"chsize"`

	// enable debug channel, used for testing
	DebugChannel bool `json:"debugch,omitempty" yaml:"debugch"`
	// contains filtered or unexported fields
}

Config contains all config

func LoadFromFile

func LoadFromFile(path string) (config Config, err error)

LoadFromFile load config from filepath

func LoadFromJSON

func LoadFromJSON(data []byte) (config Config, err error)

LoadFromJSON load config from []byte in JSON format

func LoadFromYAML

func LoadFromYAML(data []byte) (config Config, err error)

LoadFromYAML load config from []byte in YAML format

func (*Config) Start

func (t *Config) Start(ctx context.Context) (err error)

Start config in goroutines

func (*Config) TestGetOutputEvent

func (t *Config) TestGetOutputEvent(timeout time.Duration) (event logevent.LogEvent, err error)

TestGetOutputEvent get an event from chOutDebug, used for testing

func (*Config) TestInputEvent

func (t *Config) TestInputEvent(event logevent.LogEvent)

TestInputEvent send an event to chInFilter, used for testing

func (*Config) Wait

func (t *Config) Wait() (err error)

Wait blocks until all filters returned, then returns the first non-nil error (if any) from them.

type ConfigRaw

type ConfigRaw map[string]interface{}

ConfigRaw is general config struct

type FilterConfig

type FilterConfig struct {
	CommonConfig
}

FilterConfig is basic filter config struct

type FilterHandler

type FilterHandler func(ctx context.Context, raw *ConfigRaw) (TypeFilterConfig, error)

FilterHandler is a handler to regist filter module

type InputConfig

type InputConfig struct {
	CommonConfig
}

InputConfig is basic input config struct

type InputHandler

type InputHandler func(ctx context.Context, raw *ConfigRaw) (TypeInputConfig, error)

InputHandler is a handler to regist input module

type MsgChan

type MsgChan chan logevent.LogEvent

MsgChan message channel type

type OutputConfig

type OutputConfig struct {
	CommonConfig
}

OutputConfig is basic output config struct

type OutputHandler

type OutputHandler func(ctx context.Context, raw *ConfigRaw) (TypeOutputConfig, error)

OutputHandler is a handler to regist output module

type TypeCommonConfig

type TypeCommonConfig interface {
	GetType() string
}

TypeCommonConfig is interface of basic config

type TypeFilterConfig

type TypeFilterConfig interface {
	TypeCommonConfig
	Event(context.Context, logevent.LogEvent) logevent.LogEvent
}

TypeFilterConfig is interface of filter module

type TypeInputConfig

type TypeInputConfig interface {
	TypeCommonConfig
	Start(ctx context.Context, msgChan chan<- logevent.LogEvent) (err error)
}

TypeInputConfig is interface of input module

type TypeOutputConfig

type TypeOutputConfig interface {
	TypeCommonConfig
	Output(ctx context.Context, event logevent.LogEvent) (err error)
}

TypeOutputConfig is interface of output module

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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