nconf

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptSecretValue

func DecryptSecretValue(value string) (string, error)

Types

type AppConfig

type AppConfig struct {
	Group            string                  `yaml:"group"`
	Name             string                  `yaml:"name"`
	Profile          string                  `yaml:"profile"`
	GOMAXPROCS       int                     `yaml:"goMaxProcs"`
	Ext              ExtConfig               `yaml:"ext"`
	GraceTermination *GraceTerminationConfig `yaml:"graceTermination"`
}

AppConfig -

func (*AppConfig) IsProfileLocal

func (c *AppConfig) IsProfileLocal() bool

IsProfileLocal -

func (*AppConfig) SetDefaultValues

func (conf *AppConfig) SetDefaultValues()

SetDefaultValues -

type Config

type Config struct {
	App        *AppConfig     `yaml:"app"`
	Log        *LogConfig     `yaml:"log"`
	DB         *DbConfig      `yaml:"db"`
	Redis      *RedisConfig   `yaml:"redis"`
	Web        *WebConfig     `yaml:"web"`
	RPC        *RPCConfig     `yaml:"rpc"`
	CronConfig *CronConfig    `yaml:"cron"`
	Metrics    *MetricsConfig `yaml:"metrics"`
}

Config data

func MustLoadConfig

func MustLoadConfig(confPath string) *Config

MustLoadConfig -

func MustLoadConfigCustom

func MustLoadConfigCustom(confPath string, customConfig interface{ SetConfig(config *Config) }) *Config

MustLoadConfigCustom -

func MustNewConfig

func MustNewConfig(bytes []byte) *Config

MustNewConfig -

func MustNewConfigCustom

func MustNewConfigCustom(bytes []byte, customConfig interface{ SetConfig(config *Config) }) *Config

MustNewConfigCustom -

func (*Config) SetDefaultValues

func (conf *Config) SetDefaultValues()

SetDefaultValues -

type CronConfig

type CronConfig struct {
	SkipIfStillRunning *bool            `yaml:"skipIfStillRunning"`
	CronJobs           []*CronJobConfig `yaml:"cronJobs"`
}

CronConfig -

func (*CronConfig) SetDefaultValues

func (conf *CronConfig) SetDefaultValues()

SetDefaultValues -

type CronJobConfig

type CronJobConfig struct {
	Name     string `yaml:"name"`
	Schedule string `yaml:"schedule"`
}

CronJobConfig -

type DbConfig

type DbConfig struct {
	Username               string        `yaml:"username"`
	Password               string        `yaml:"password"`
	Host                   string        `yaml:"host"`
	Port                   int32         `yaml:"port"`
	Database               string        `yaml:"database"`
	Charset                string        `yaml:"charset"`
	MaxIdle                int32         `yaml:"maxIdle"`
	MaxIdleTime            time.Duration `yaml:"maxIdleTime"`
	MaxOpen                int32         `yaml:"maxOpen"`
	MaxLifetime            time.Duration `yaml:"maxLifetime"`
	SlowQueryThreshold     time.Duration `yaml:"slowQueryThreshold"`
	SkipDefaultTransaction *bool         `yaml:"skipDefaultTransaction"`
	PrepareStmt            *bool         `yaml:"prepareStmt"`
}

DbConfig -

func (*DbConfig) SetDefaultValues

func (conf *DbConfig) SetDefaultValues()

SetDefaultValues -

type ExtConfig

type ExtConfig map[string]interface{}

ExtConfig -

func (ExtConfig) BoolVal

func (e ExtConfig) BoolVal(key string) bool

BoolVal -

func (ExtConfig) IntVal

func (e ExtConfig) IntVal(key string) int

IntVal -

func (ExtConfig) StrVal

func (e ExtConfig) StrVal(key string) string

StrVal -

type GraceTerminationConfig

type GraceTerminationConfig struct {
	GraceTerminationPeriod time.Duration `yaml:"graceTerminationPeriod"`
}

GraceTerminationConfig -

func (*GraceTerminationConfig) SetDefaultValues

func (conf *GraceTerminationConfig) SetDefaultValues()

SetDefaultValues -

type LogConfig

type LogConfig struct {
	Level           string `yaml:"level"`
	Format          string `yaml:"format"`
	PrettyPrint     bool   `yaml:"prettyPrint"`
	CallerPrint     bool   `yaml:"callerPrint"`
	TimestampFormat string `yaml:"timestampFormat"`
	LogPath         string `yaml:"logPath"`
	LogFilename     string `yaml:"logFilename"`
}

LogConfig -

func (*LogConfig) SetDefaultValues

func (conf *LogConfig) SetDefaultValues()

SetDefaultValues -

type MetricsConfig

type MetricsConfig struct {
	Host               string `yaml:"host"`
	Port               int32  `yaml:"port"`
	MetricsPath        string `yaml:"metricsPath"`
	BuildInfoCollector *bool  `yaml:"buildInfoCollector"`
	ProcessCollector   *bool  `yaml:"processCollector"`
	GoCollector        *bool  `yaml:"goCollector"`
}

MetricsConfig -

func (*MetricsConfig) SetDefaultValues

func (conf *MetricsConfig) SetDefaultValues()

SetDefaultValues -

type RPCClientConfig

type RPCClientConfig struct {
	Addr               string `yaml:"addr"`
	Plaintext          *bool  `yaml:"plaintext"`
	InsecureSkipVerify bool   `yaml:"insecureSkipVerify"`
	MaxCallSendMsgSize int    `yaml:"maxCallSendMsgSize"`
	MaxCallRecvMsgSize int    `yaml:"maxCallRecvMsgSize"`
}

RPCClientConfig -

func (*RPCClientConfig) SetDefaultValues

func (conf *RPCClientConfig) SetDefaultValues()

SetDefaultValues -

type RPCConfig

type RPCConfig struct {
	Host                     string                      `yaml:"host"`
	Port                     int32                       `yaml:"port"`
	MaxRecvMsgSize           int64                       `yaml:"maxRecvMsgSize"`
	RegisterHealthServer     *bool                       `yaml:"registerHealthServer"`
	RegisterReflectionServer *bool                       `yaml:"registerReflectionServer"`
	Clients                  map[string]*RPCClientConfig `yaml:"clients"`
}

RPCConfig -

func (*RPCConfig) SetDefaultValues

func (conf *RPCConfig) SetDefaultValues()

SetDefaultValues -

type RedisClusterConfig

type RedisClusterConfig struct {
	// Addrs - A list of "host:port" pairs to bootstrap from. This represents an "initial" list of cluster nodes and is required to have at least one entry.
	Addrs []string `yaml:"addrs"`
	// MaxRedirects -Maximum number of redirects to follow when executing commands across the cluster.
	MaxRedirects int32 `yaml:"maxRedirects"`
}

RedisClusterConfig -

type RedisConfig

type RedisConfig struct {
	Password        string               `yaml:"password"`
	Host            string               `yaml:"host"`
	Port            int32                `yaml:"port"`
	Database        uint8                `yaml:"database"`
	IdleTimeout     time.Duration        `yaml:"idleTimeout"`
	MaxConnLifetime time.Duration        `yaml:"maxConnLifetime"`
	MaxIdle         int32                `yaml:"maxIdle"`
	MaxActive       int32                `yaml:"maxActive"`
	TestOnBorrow    bool                 `yaml:"testOnBorrow"`
	Sentinel        *RedisSentinelConfig `yaml:"sentinel"`
	Cluster         *RedisClusterConfig  `yaml:"cluster"`
}

RedisConfig -

func (*RedisConfig) SetDefaultValues

func (conf *RedisConfig) SetDefaultValues()

SetDefaultValues -

type RedisSentinelConfig

type RedisSentinelConfig struct {
	// Master - MasterName is a name of Redis master Sentinel servers monitor(Name of the Redis server).
	Master string `yaml:"master"`
	// Addrs - Addrs is a slice of with known Sentinel addresses (A list of "host:port" pairs).
	Addrs []string `yaml:"addrs"`
}

RedisSentinelConfig -

type SecretsConfig

type SecretsConfig interface {
	SecretKey() string
	DecryptSecrets() error
}

type SwaggerConfig

type SwaggerConfig struct {
	Enabled bool   `yaml:"enabled"`
	URL     string `yaml:"url"`
}

SwaggerConfig -

type WebConfig

type WebConfig struct {
	Host               string              `yaml:"host"`
	Port               int32               `yaml:"port"`
	Swagger            *SwaggerConfig      `yaml:"swagger"`
	MaxMultipartMemory int64               `yaml:"maxMultipartMemory"`
	SensitiveURLPaths  map[string]struct{} `yaml:"sensitiveURLPaths"`
}

WebConfig -

func (*WebConfig) IsSensitiveURLPath added in v0.7.0

func (conf *WebConfig) IsSensitiveURLPath(path string) bool

func (*WebConfig) SetDefaultValues

func (conf *WebConfig) SetDefaultValues()

SetDefaultValues -

Jump to

Keyboard shortcuts

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