1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-02-01 13:07:48 +02:00
kratos/config/options.go

39 lines
655 B
Go
Raw Normal View History

2021-02-17 17:14:47 +08:00
package config
import (
"github.com/go-kratos/kratos/v2/log"
)
// Decoder is config decoder.
type Decoder func(*KeyValue, map[string]interface{}) error
// Option is config option.
type Option func(*options)
type options struct {
sources []Source
decoder Decoder
logger log.Logger
}
// WithSource with config source.
func WithSource(s ...Source) Option {
return func(o *options) {
o.sources = s
}
}
// WithDecoder with config decoder.
func WithDecoder(d Decoder) Option {
return func(o *options) {
o.decoder = d
}
}
// WithLogger with config logger.
2021-02-17 17:14:47 +08:00
func WithLogger(l log.Logger) Option {
return func(o *options) {
o.logger = l
}
}