config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCreds

GetCreds returns transport credentials based on the tls config.

func GetDefaultLogger

func GetDefaultLogger() *zap.Logger

GetDefaultLogger creates default zap logger.

func GetLogger

func GetLogger(zCfg *zap.Config) *zap.Logger

GetLogger returns logger based on the configuration.

func GetTLS

func GetTLS(cfg *TLSConfig) (*tls.Config, error)

GetTLS returns tls.config based on the configuration.

func Transform

func Transform(cfg interface{}, d interface{}) error

Transform transforms one data structure to another it uses to transform map[string]interface{} config to specific struct.

Types

type Config

type Config struct {
	Tracepoints []Tracepoint
	Fields      map[string][]Field
	Egress      map[string]EgressConfig
	Log         *zap.Config
	// contains filtered or unexported fields
}

Config represents tcpstats's config

func FromContext

func FromContext(ctx context.Context) *Config

FromContext returns configuration from context.

func Get

func Get(args []string, version string) (*Config, error)

Get returns the configuration based on the file or cli

func (*Config) GetTPFields

func (c *Config) GetTPFields(name string) []string

GetTPFields returns a tracepoint fields.

func (*Config) Logger

func (c *Config) Logger() *zap.Logger

Logger returns logger.

func (*Config) SetMockLogger

func (c *Config) SetMockLogger(scheme string) *MemSink

SetMockLogger sets in memory logger

func (*Config) WithContext

func (c *Config) WithContext(ctx context.Context) context.Context

WithContext returns new context including configuration.

type EgressConfig

type EgressConfig struct {
	Type   string
	Config map[string]interface{}
}

EgressConfig represents egress configuration.

type Field

type Field struct {
	Name   string `yaml:"name"`
	Math   string `yaml:"math,omitempty"`
	Filter string `yaml:"filter,omitempty"`
}

Field represents a field.

type Flow

type Flow struct {
	Ingress       string
	Ingestion     string
	Serialization string
}

Flow represents flow from an ingress to an ingestion

type Geo

type Geo struct {
	Type   string            `yaml:"type"`
	Config map[string]string `yaml:"config"`
}

Geo represents a geo

type Ingestion

type Ingestion struct {
	Type   string                 `yaml:"type"`
	Config map[string]interface{} `yaml:"config"`
}

Ingestion represents an ingestion

type Ingress

type Ingress struct {
	Type   string                 `yaml:"type"`
	Config map[string]interface{} `yaml:"config"`
}

Ingress represents an ingress

type MemSink

type MemSink struct {
	*bytes.Buffer
}

MemSink represents logging in memory

func (*MemSink) Close

func (s *MemSink) Close() error

Close is required method for sink interface.

func (*MemSink) Sync

func (s *MemSink) Sync() error

Sync is required method for sink interface.

func (*MemSink) Unmarshal

func (s *MemSink) Unmarshal() map[string]string

Unmarshal returns decoded data as key value and reset the buffer.

type ServerConfig

type ServerConfig struct {
	Ingress   map[string]Ingress
	Ingestion map[string]Ingestion
	Flow      []Flow
	Geo       Geo
	Log       *zap.Config
	// contains filtered or unexported fields
}

ServerConfig represents server configuration

func FromContextServer

func FromContextServer(ctx context.Context) *ServerConfig

FromContextServer returns configuration from context

func GetServer

func GetServer(args []string, version string) (*ServerConfig, error)

GetServer returns configuration

func (*ServerConfig) Logger

func (c *ServerConfig) Logger() *zap.Logger

Logger returns logger

func (*ServerConfig) SetMockLogger

func (c *ServerConfig) SetMockLogger(scheme string) *MemSink

SetMockLogger sets the in memory logger

func (*ServerConfig) WithContext

func (c *ServerConfig) WithContext(ctx context.Context) context.Context

WithContext returns new context including configuration

type TLSConfig

type TLSConfig struct {
	Enable   bool
	Insecure bool
	CertFile string `yaml:"certFile"`
	KeyFile  string `yaml:"keyFile"`
	CAFile   string `yaml:"caFile"`
}

TLSConfig represents TLS configuration.

type Tracepoint

type Tracepoint struct {
	Name     string `yaml:"name"`
	Fields   string `yaml:"fields"`
	TCPState string `yaml:"tcp_state"`
	Sample   int    `yaml:"sample"`
	Workers  int    `yaml:"workers"`
	INet     []int  `yaml:"inet"`
	Egress   string `yaml:"egress"`
}

Tracepoint represents a tracepoint's config.

Jump to

Keyboard shortcuts

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