source

package
v0.0.0-...-88236ff Latest Latest
Warning

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

Go to latest
Published: May 25, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string
const (
	Created Action = "Created"
	Updated Action = "Updated"
	Deleted Action = "Deleted"
)

type BaseSource

type BaseSource struct {
	// contains filtered or unexported fields
}

func (*BaseSource) AddPath

func (bs *BaseSource) AddPath(path string, opts ...PathOption) error

添加配置

func (*BaseSource) All

func (bs *BaseSource) All() (values map[string]interface{})

获取所有的配置

func (*BaseSource) Client

func (bs *BaseSource) Client() client.Client

func (*BaseSource) Close

func (bs *BaseSource) Close() error

func (*BaseSource) Get

func (bs *BaseSource) Get(key string) (value interface{}, ok bool)

获取单个配置

func (*BaseSource) Keys

func (bs *BaseSource) Keys() (keys []string)

获取所有的key

func (*BaseSource) Name

func (bs *BaseSource) Name() string

func (*BaseSource) OnEvents

func (bs *BaseSource) OnEvents(cb func([]*Event))

设置回调

func (*BaseSource) Priority

func (bs *BaseSource) Priority() int

func (*BaseSource) Set

func (bs *BaseSource) Set(key string, value interface{})

设置配置

type Event

type Event struct {
	Action    Action      `json:"action,omitempty"`
	Source    string      `json:"source,omitempty"`
	Path      string      `json:"path,omitempty"`
	Key       string      `json:"key,omitempty"`
	ValueFrom interface{} `json:"vFrom,omitempty"`
	ValueTo   interface{} `json:"vTo,omitempty"`
}

func NewEvent

func NewEvent(action Action, key string) *Event

func (*Event) String

func (e *Event) String() string

type Option

type Option func(opts *options)

func WithDeleted

func WithDeleted() Option

func WithPrefix

func WithPrefix(prefix string) Option

func WithPriority

func WithPriority(priority int) Option

type PathOption

type PathOption func(opts *pathOptions)

func WithPathParser

func WithPathParser(parser parser.Parser) PathOption

func WithPathPriority

func WithPathPriority(pri int) PathOption

func WithPathRequired

func WithPathRequired() PathOption

func WithPathWatchDisabled

func WithPathWatchDisabled() PathOption

type Source

type Source interface {
	io.Closer
	Name() string
	Client() client.Client

	// 优先级
	Priority() int

	// 获取所有的key
	Keys() (keys []string)
	// 获取所有的配置
	All() (values map[string]interface{})
	// 获取单个配置
	Get(key string) (value interface{}, ok bool)
	// 设置配置
	Set(key string, value interface{})
	// 添加配置集合
	AddPath(path string, opts ...PathOption) (err error)
	// 设置回调
	OnEvents(cb func([]*Event))
}

Source 管理客户端的多个配置集合, 目前配置集没有优先级

func New

func New(name string, c client.Client, opts ...Option) Source

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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