Documentation ¶
Index ¶
- Constants
- Variables
- func DumpDemoCfg(cfg interface{})
- func TomlMarshalIndent(cfg interface{}) (string, error)
- func TomlUnmarshaler(p []byte, v interface{}) error
- func ValidateConfig(cfg interface{}) error
- type Base
- type BaseConfigEmbedded
- type BeforeInspectHook
- type ChangeListener
- type ConfigLoader
- type FileProvider
- type FlagParseResult
- type FlagParser
- type FlagSet
- type GoRedisConfig
- type InspectConfig
- type LogConfig
- type LogEncoding
- type Logger
- type LoggerConfig
- type MongoConfig
- type MysqlConfig
- type NacosClient
- type NacosProvider
- type Option
- func WithBeforeInspectHook(opt BeforeInspectHook) Option
- func WithCustomUnmarshaler(opt Unmarshaler) Option
- func WithDumpMarshalledConfig(opt bool) Option
- func WithFlagParser(opt FlagParser) Option
- func WithInspectConfig(opt InspectConfig) Option
- func WithLogger(opt Logger) Option
- func WithProviders(opt ...Provider) Option
- func WithRegisterFlags(opt RegisterFlags) Option
- func WithServiceName(opt string) Option
- func WithServiceVersion(opt string) Option
- func WithShortDescription(opt string) Option
- func WithUsage(opt string) Option
- type Provider
- type RegisterFlags
- type TextProvider
- type Unmarshaler
Constants ¶
View Source
const ( // EnvNacosHost compatible with old one like: EnvNacosHost = "NACOS_HOST" EnvNacosPort = "NACOS_PORT" EnvNacosNamespace = "NACOS_NAMESPACE" EnvNacosGroup = "NACOS_GROUP" EnvNacosDataID = "NACOS_DATAID" EnvNacosLogLevel = "NACOS_LOG_LEVEL" EnvOtlpGrpcEndpoint = "OTLP_GRPC_ENDPOINT" FlagConfigFile = "config" FlagDumpConfig = "dump" DefaultLogLevel = "info" // DefaultLogLevelNacos oops, nacos logging debug log as info level DefaultLogLevelNacos = "error" DefaultLogEncoding = LogEncodingJSON DefaultLogOutput = "stderr" )
Variables ¶
View Source
var ErrEmptyConfig = errors.New("got empty config")
View Source
var ErrEmptyConfigFile = errors.New("error empty config file")
View Source
var ErrSkipProvider = errors.New("skip provider")
Functions ¶
func DumpDemoCfg ¶
func DumpDemoCfg(cfg interface{})
DumpDemoCfg dump the config to stdout and exit the app nolint: forbidigo
func TomlMarshalIndent ¶
func TomlUnmarshaler ¶
func ValidateConfig ¶
func ValidateConfig(cfg interface{}) error
Types ¶
type Base ¶
type Base struct { Tracing bool `toml:"tracing" yaml:"tracing" json:"tracing"` // opentelemetry tracing Profile bool `toml:"profile" yaml:"profile" json:"profile"` // go profiling Metric bool `toml:"metric" yaml:"metric" json:"metric"` // prometheus metrics MetricGo bool `toml:"metric_go" yaml:"metric_go" json:"metric_go"` // prometheus go metrics MetricProcess bool `toml:"metric_process" yaml:"metric_process" json:"metric_process"` // prometheus process metrics OtlpGrpcEndpoint string `toml:"otlp_grpc_endpoint" yaml:"otlp_grpc_endpoint" json:"otlp_grpc_endpoint"` Log LogConfig `toml:"log" yaml:"log" json:"log"` }
Base is the common config save your ass
func (*Base) InitOtlpGrpcEndpointFromEnv ¶
func (b *Base) InitOtlpGrpcEndpointFromEnv()
type BaseConfigEmbedded ¶
type BaseConfigEmbedded interface {
InitOtlpGrpcEndpointFromEnv()
}
type BeforeInspectHook ¶
type BeforeInspectHook func(config interface{})
type ChangeListener ¶
type ChangeListener func(namespace, group, dataId, data string)
type ConfigLoader ¶
type ConfigLoader struct {
// contains filtered or unexported fields
}
func New ¶
func New(opts ...Option) *ConfigLoader
func (*ConfigLoader) Load ¶
func (cl *ConfigLoader) Load(cfg interface{}) error
type FileProvider ¶
type FileProvider struct { DefaultConfigPath string SkipIfPathEmpty bool // skip this provider if config file path is empty SkipIfDefaultNotExist bool }
func (*FileProvider) Config ¶
func (p *FileProvider) Config(helper *providerHelper) ([]byte, error)
func (*FileProvider) Name ¶
func (p *FileProvider) Name() string
type FlagParseResult ¶
type FlagParser ¶
type FlagParser func() FlagParseResult
type GoRedisConfig ¶
type InspectConfig ¶
type InspectConfig func(config interface{}) error
type LogConfig ¶
type LogConfig struct { // Level set log level, can be empty, or one of debug|info|warn|error|fatal|panic Level string `toml:"level" json:"level" yaml:"level"` // Output set output file path, can be filepath or stdout|stderr Output string `toml:"output" json:"output" yaml:"output"` // Encoding sets the logger's encoding. Valid values are "json" and "console". default: json Encoding LogEncoding `toml:"encoding" json:"encoding" yaml:"encoding"` // enable stacktrace DisableStacktrace bool `toml:"disable_stacktrace" json:"disable_stacktrace" yaml:"disable_stacktrace"` }
func (*LogConfig) GetDisableStacktrace ¶
func (*LogConfig) GetEncoding ¶
func (*LogConfig) GetInitialFields ¶
type LogEncoding ¶
type LogEncoding string
const ( LogEncodingJSON LogEncoding = "json" LogEncodingConsole LogEncoding = "console" )
the default is json, if not empty, must be one of: console|json
type Logger ¶
type Logger interface { // nolint: gofumpt Debugw(msg string, keysAndValues ...interface{}) Infow(msg string, keysAndValues ...interface{}) Warnw(msg string, keysAndValues ...interface{}) Errorw(msg string, keysAndValues ...interface{}) Fatalw(msg string, keysAndValues ...interface{}) }
Logger is the interface that wraps the basic Log methods for usage only in the config init stage
type LoggerConfig ¶
type MongoConfig ¶
type MongoConfig struct { DB string `toml:"db" json:"db" yaml:"db" validate:"required"` // URI https://www.mongodb.com/docs/manual/reference/connection-string/ URI string `toml:"uri" yaml:"uri" json:"uri" validate:"required"` Tracing bool `toml:"tracing" json:"tracing" long:"tracing" yaml:"tracing" description:"enable tracing middleware"` }
type MysqlConfig ¶
type MysqlConfig struct { Dsn string `toml:"dsn" yaml:"dsn" json:"dsn" validate:"required"` // data source name MaxOpenCount int `toml:"max_open_count" json:"max_open_count" validate:"required" yaml:"max_open_count"` MaxIdleCount int `toml:"max_idle_count" json:"max_idle_count" validate:"required" yaml:"max_idle_count"` Tracing bool `toml:"tracing" json:"tracing" yaml:"tracing"` }
type NacosClient ¶
type NacosClient struct {
// contains filtered or unexported fields
}
type NacosProvider ¶
type NacosProvider struct { ChangeListener ChangeListener NacosLogger nacosLogger.Logger // custom logger for replacing nacos default logger LogLevel string // log level for nacos default logger }
func (*NacosProvider) Config ¶
func (p *NacosProvider) Config(helper *providerHelper) ([]byte, error)
func (*NacosProvider) Name ¶
func (p *NacosProvider) Name() string
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithBeforeInspectHook ¶
func WithBeforeInspectHook(opt BeforeInspectHook) Option
func WithCustomUnmarshaler ¶
func WithCustomUnmarshaler(opt Unmarshaler) Option
func WithFlagParser ¶
func WithFlagParser(opt FlagParser) Option
func WithInspectConfig ¶
func WithInspectConfig(opt InspectConfig) Option
func WithLogger ¶
WithLogger init the logger config for infra.config package, before app start the name ref to "Early KMS start"
func WithProviders ¶
func WithRegisterFlags ¶
func WithRegisterFlags(opt RegisterFlags) Option
WithRegisterFlags is used for add extra cli flags before parse args
func WithServiceName ¶
func WithServiceVersion ¶
func WithShortDescription ¶
type RegisterFlags ¶
type RegisterFlags func(flag *FlagSet)
type TextProvider ¶
type TextProvider struct {
ConfigText []byte
}
func (*TextProvider) Config ¶
func (p *TextProvider) Config(helper *providerHelper) ([]byte, error)
func (*TextProvider) Name ¶
func (p *TextProvider) Name() string
type Unmarshaler ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.