Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9dbd75f

Browse files
authored
Config interface change (micro#2010)
1 parent 8975184 commit 9dbd75f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+476
-3301
lines changed

config/config.go

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,41 @@
22
package config
33

44
import (
5-
"context"
6-
7-
"github.com/micro/go-micro/v3/config/loader"
8-
"github.com/micro/go-micro/v3/config/reader"
9-
"github.com/micro/go-micro/v3/config/source"
5+
"time"
106
)
117

128
// Config is an interface abstraction for dynamic configuration
139
type Config interface {
14-
// provide the reader.Values interface
15-
reader.Values
16-
// Init the config
17-
Init(opts ...Option) error
18-
// Options in the config
19-
Options() Options
20-
// Stop the config loader/watcher
21-
Close() error
22-
// Load config sources
23-
Load(source ...source.Source) error
24-
// Force a source changeset sync
25-
Sync() error
26-
// Watch a value for changes
27-
Watch(path ...string) (Watcher, error)
10+
Get(path string, options ...Option) Value
11+
Set(path string, val interface{}, options ...Option)
12+
Delete(path string, options ...Option)
2813
}
2914

30-
// Watcher is the config watcher
31-
type Watcher interface {
32-
Next() (reader.Value, error)
33-
Stop() error
15+
// Value represents a value of any type
16+
type Value interface {
17+
Exists() bool
18+
Bool(def bool) bool
19+
Int(def int) int
20+
String(def string) string
21+
Float64(def float64) float64
22+
Duration(def time.Duration) time.Duration
23+
StringSlice(def []string) []string
24+
StringMap(def map[string]string) map[string]string
25+
Scan(val interface{}) error
26+
Bytes() []byte
3427
}
3528

3629
type Options struct {
37-
Loader loader.Loader
38-
Reader reader.Reader
39-
Source []source.Source
40-
41-
// for alternative data
42-
Context context.Context
30+
// Is the value being read a secret?
31+
// If true, the Config will try to decode it with `SecretKey`
32+
Secret bool
4333
}
4434

35+
// Option sets values in Options
4536
type Option func(o *Options)
4637

47-
// NewConfig returns new config
48-
func NewConfig(opts ...Option) (Config, error) {
49-
return newConfig(opts...)
38+
func Secret(isSecret bool) Option {
39+
return func(o *Options) {
40+
o.Secret = isSecret
41+
}
5042
}

config/default.go

Lines changed: 0 additions & 301 deletions
This file was deleted.

0 commit comments

Comments
 (0)