config

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cover

func Cover(path string, config *Config) error

func MakeDir

func MakeDir(path string) error

func RandSecret

func RandSecret() ([]byte, error)

RandSecret If the daemon does not have a secret key configured, it is automatically generated

Types

type Config

type Config struct {
	Listen       string        `json:"listen"`
	ReadTimeout  time.Duration `json:"readTimeout"`
	WriteTimeout time.Duration `json:"writeTimeout"`
	IdleTimeout  time.Duration `json:"idleTimeout"`
	Log          *LogConfig    `json:"log"`
	DB           *DBConfig     `json:"db"`

	Trace   *metrics.TraceConfig   `json:"traceConfig"`
	Metrics *metrics.MetricsConfig `json:"metricsExporter"`
}

func DecodeConfig

func DecodeConfig(path string) (c *Config, err error)

func DefaultConfig

func DefaultConfig() *Config

type DBConfig

type DBConfig struct {
	Type         DBType        `json:"type"`
	DSN          string        `json:"dsn"`
	MaxOpenConns int           `json:"maxOpenConns"`
	MaxIdleConns int           `json:"maxIdleConns"`
	MaxLifeTime  time.Duration `json:"maxLifeTime"`
	MaxIdleTime  time.Duration `json:"maxIdleTime"`
	Debug        bool          `json:"debug"`
}

type DBType

type DBType = string
const (
	Mysql  DBType = "mysql"
	Badger DBType = "badger"
)

type InfluxDBConfig

type InfluxDBConfig struct {
	ServerURL     string        `json:"serverURL"`
	AuthToken     string        `json:"authToken"`
	Org           string        `json:"org"`
	Bucket        string        `json:"bucket"`
	FlushInterval time.Duration `json:"flushInterval"`
	BatchSize     uint          `json:"batchSize"`
}

type LogConfig

type LogConfig struct {
	LogLevel   string          `json:"logLevel"`
	Type       LogHookType     `json:"type"`
	HookSwitch bool            `json:"hookSwitch"`
	InfluxDB   *InfluxDBConfig `json:"influxdb"`
}

type LogHookType

type LogHookType = int
const (
	LHTInfluxDB LogHookType = 1
)

type Provider

type Provider interface {
	GetString(key string) string
	GetInt(key string) int
	GetBool(key string) bool
	GetStringMap(key string) map[string]interface{}
	GetStringMapString(key string) map[string]string
	GetStringSlice(key string) []string
	Get(key string) interface{}
	Set(key string, value interface{})
	IsSet(key string) bool
	WatchConfig()
	OnConfigChange(run func(in fsnotify.Event))
	Unmarshal(rawVal interface{}, opts ...viper.DecoderConfigOption) error
	UnmarshalKey(key string, rawVal interface{}, opts ...viper.DecoderConfigOption) error
}

func FromConfigString

func FromConfigString(path, configType string) (Provider, error)

FromConfigString creates a config from the given YAML, JSON or TOML config. This is useful in tests.

Jump to

Keyboard shortcuts

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