You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
655 B
38 lines
655 B
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.
|
|
func WithLogger(l log.Logger) Option {
|
|
return func(o *options) {
|
|
o.logger = l
|
|
}
|
|
}
|
|
|