config

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is key not found.
	ErrNotFound = errors.New("key not found")
	// ErrTypeAssert is type assert error.
	ErrTypeAssert = errors.New("type assert error")
)

Functions

This section is empty.

Types

type ChangedListener

type ChangedListener interface {
	// Changed 指定配置变化后的通知接口,标示变化的路径和变化后的vars(变化后的新数据值)。
	Changed(vars map[string]string)
}

ChangedListener 配置数据发生变化时的监听器接口。

type Config

type Config struct {
	AuthToken      string
	AuthType       string
	BasicAuth      bool
	ClientCaKeys   string
	ClientCert     string
	ClientKey      string
	ClientInsecure bool
	BackendNodes   Nodes
	Username       string
	Password       string
	Scheme         string
	Table          string
	Separator      string
	AppID          string
	UserID         string
	RoleID         string
	SecretID       string
	YamlFile       Nodes
	Filter         string
	Path           string
	Role           string
}

type Configuration

type Configuration interface {
	Value(key string) Value
	Watch(prefix string, key []string, o ChangedListener) error
	Close() error
}

Configuration 是一个配置接口.

func New

func New(opts ...Option) Configuration

New 使用选项新建配置.

type Nodes

type Nodes []string

Nodes 是一个自定义标志Var,代表etcd节点的列表.

func (*Nodes) Set

func (n *Nodes) Set(node string) error

Set 将节点追加到etcd节点列表中.

func (*Nodes) String

func (n *Nodes) String() string

String 返回节点var的字符串表示形式.

type Option

type Option func(*options)

Option 是配置选项.

func WithErrorChan

func WithErrorChan(errChan chan error) Option

func WithLogger

func WithLogger(l log.Logger) Option

WithLogger 配置记录器.

func WithStopChan

func WithStopChan(stopChan chan bool) Option

func WithStore

func WithStore(s ...StoreClient) Option

WithStore 配置数据后端存储.

type Processor

type Processor interface {
	Process(listener ChangedListener)
}

func WatchProcessor

func WatchProcessor(prefix string, keys []string, stopChan chan bool, errChan chan error, store StoreClient) Processor

type StoreClient

type StoreClient interface {
	GetValues(keys []string) (map[string]string, error)
	WatchPrefix(prefix string, keys []string, waitIndex uint64, stopChan chan bool) (uint64, error)
	Close() error
}

StoreClient 接口由可以从后端存储检索键/值对的对象实现.

type Value

type Value interface {
	Bool() (bool, error)
	Int() (int64, error)
	Float() (float64, error)
	String() (string, error)
	Duration() (time.Duration, error)
	Scan(interface{}) error
}

Value 是配置值接口.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL