Skip to content

Commit

Permalink
Config interface change (micro#2010)
Browse files Browse the repository at this point in the history
  • Loading branch information
crufter authored Sep 21, 2020
1 parent 8975184 commit 9dbd75f
Show file tree
Hide file tree
Showing 50 changed files with 476 additions and 3,301 deletions.
56 changes: 24 additions & 32 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,41 @@
package config

import (
"context"

"github.com/micro/go-micro/v3/config/loader"
"github.com/micro/go-micro/v3/config/reader"
"github.com/micro/go-micro/v3/config/source"
"time"
)

// Config is an interface abstraction for dynamic configuration
type Config interface {
// provide the reader.Values interface
reader.Values
// Init the config
Init(opts ...Option) error
// Options in the config
Options() Options
// Stop the config loader/watcher
Close() error
// Load config sources
Load(source ...source.Source) error
// Force a source changeset sync
Sync() error
// Watch a value for changes
Watch(path ...string) (Watcher, error)
Get(path string, options ...Option) Value
Set(path string, val interface{}, options ...Option)
Delete(path string, options ...Option)
}

// Watcher is the config watcher
type Watcher interface {
Next() (reader.Value, error)
Stop() error
// Value represents a value of any type
type Value interface {
Exists() bool
Bool(def bool) bool
Int(def int) int
String(def string) string
Float64(def float64) float64
Duration(def time.Duration) time.Duration
StringSlice(def []string) []string
StringMap(def map[string]string) map[string]string
Scan(val interface{}) error
Bytes() []byte
}

type Options struct {
Loader loader.Loader
Reader reader.Reader
Source []source.Source

// for alternative data
Context context.Context
// Is the value being read a secret?
// If true, the Config will try to decode it with `SecretKey`
Secret bool
}

// Option sets values in Options
type Option func(o *Options)

// NewConfig returns new config
func NewConfig(opts ...Option) (Config, error) {
return newConfig(opts...)
func Secret(isSecret bool) Option {
return func(o *Options) {
o.Secret = isSecret
}
}
301 changes: 0 additions & 301 deletions config/default.go

This file was deleted.

Loading

0 comments on commit 9dbd75f

Please sign in to comment.