common

package
v0.0.0-...-38f40ef Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2017 License: MPL-2.0 Imports: 15 Imported by: 7

Documentation

Overview

Package common contains the structs and logic that form the basis of protonds operation.

All other protond modules rely on a subset of the functionality provided here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseEventData

func ParseEventData(str string) (map[string]interface{}, error)

ParseEventData will convert the supplied string to an Event struct pointer.

func PathExists

func PathExists(path string) bool

PathExists determines whether or not the specified path exists on disk.

Types

type Config

type Config struct {
	ConfFile        string          ``            /* 174-byte string literal not displayed */
	Backlog         int             ``            /* 173-byte string literal not displayed */
	NumWorkers      int             ``            /* 206-byte string literal not displayed */
	FilterTimeout   time.Duration   ``            /* 199-byte string literal not displayed */
	InputDirectory  string          ``            /* 212-byte string literal not displayed */
	OutputDirectory string          ``            /* 212-byte string literal not displayed */
	FilterDirectory string          ``            /* 216-byte string literal not displayed */
	DataDir         string          ``            /* 169-byte string literal not displayed */
	PidFile         string          ``            /* 173-byte string literal not displayed */
	Log             *Logger         `skip:"true"` // The internal logger to use
	Inputs          []*PluginConfig `skip:"true"` // The raw input configurations to use for event ingestion
	Outputs         []*PluginConfig `skip:"true"` // The raw input configurations to use for event propagation
	Filters         []*FilterConfig `skip:"true"` // The raw javascript filters to use during event filtering
	// contains filtered or unexported fields
}

Config struct that handles marshalling in user supplied configuration data from cli arguments, environment variables, and configuration file entries.

The user supplied configuration is processed via a structured hierarchy:

  • Cli arguments override both environment variables and configuration file entries.
  • Environment variables will override file entries but can be overridden by cli arguments.
  • Configuration file entries will be overridden by both environment variables and cli arguments.
  • Defaults are used in the case that the use does not define a configuration argument.

The only exceptions to the above are the two special cli argments '-h'|'--help' or '-v'|'--version' which will output usage information or version information respectively and then exit the application.

func NewConfig

func NewConfig(log *Logger) (*Config, error)

NewConfig creates a new Config struct based on user supplied input.

type Event

type Event struct {
	Timestamp time.Time              `json:"timestamp"`
	Input     string                 `json:"input"`
	Data      map[string]interface{} `json:"data"`
}

Event represents an arbitrary event passing through protond.

func (*Event) Bytes

func (e *Event) Bytes(pretty bool) []byte

Bytes will return the byte slice representation of the event struct, optionally "pretty" printed, if there is an error during the marshalling process the returned byte slice will be nil.

func (*Event) String

func (e *Event) String(pretty bool) string

String will return the string representation of the event struct, optionally "pretty" printed, if there is an error during the marshalling process the returned string will be empty.

type FilterConfig

type FilterConfig struct {
	Type string
	Name string
	Code string
}

FilterConfig is a struct representing a javascript filters name and underlying code.

type Logger

type Logger struct {
	Plain *log.Logger
	Error *log.Logger
	Info  *log.Logger
	Warn  *log.Logger
	Debug *log.Logger
}

Logger struct which allows for a single global point for logging configuration.

func NewLogger

func NewLogger(loggerType LoggerType) *Logger

NewLogger creates a new logger struct based on the supplied LoggerType.

type LoggerType

type LoggerType int

LoggerType will determine the logging level of the logger object created.

const (
	// NoopLogger will noop all logging calls this is only used for testing.
	NoopLogger LoggerType = iota

	// ErrorLogger will only output error logs.
	ErrorLogger

	// WarnLogger will output warn/error logs.
	WarnLogger

	// InfoLogger will output info/warn/error logs.
	InfoLogger

	// DebugLogger will output debug/info/warn/error logs.
	DebugLogger
)

type PluginConfig

type PluginConfig struct {
	Type   string            `json:"type" yaml:"type"`
	Name   string            `json:"name" yaml:"name"`
	Config map[string]string `json:"config" yaml:"config"`
}

PluginConfig is a struct representing a input plugin configuration.

func ParsePluginConfigs

func ParsePluginConfigs(dir string, log *Logger) ([]*PluginConfig, error)

ParsePluginConfigs parses a directory of files and returns the resulting array of configs.

type Signaler

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

Signaler struct used to manage os and user signals to the protond process.

func NewSignaler

func NewSignaler(log *Logger, config *Config, fds []int, env map[string]string) *Signaler

NewSignaler generates a new Signaler object, which will watch for new os and user signals passed to the protond process.

func (*Signaler) Wait

func (sig *Signaler) Wait(exec bool) error

Wait for a configured os or user signal to be passed to the protond process.

Jump to

Keyboard shortcuts

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