watcher

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

README

watcher

  1. watcher组件是对file, etcd, 等其他组件的抽象
  2. watcher组件会更新全局的配置
  3. watcher组件管理所有的watcher的实现

Documentation

Index

Constants

View Source
const Name = "watcher"

Variables

This section is empty.

Functions

func Decode added in v0.1.2

func Decode(data []byte, c interface{}) (err error)

func Init added in v0.0.21

func Init() (err error)

func KeyToDot

func KeyToDot(prefix ...string) string

KeyToDot /projectName/foo/bar --> projectName.foo.bar

func Register

func Register(name string, w Factory)

func Watch

func Watch(name string, plg plugin.Plugin)

Types

type CallBack

type CallBack func(name string, resp *Response) error

type Cfg

type Cfg struct {
	SkipNull bool     `json:"skip_null"`
	Driver   string   `json:"driver"`
	Projects []string `json:"projects"`
	Exclude  []string `json:"exclude"`
}

func GetDefaultCfg

func GetDefaultCfg() Cfg

func (Cfg) Build

func (cfg Cfg) Build() (_ Watcher, err error)

type Factory

type Factory func(cfg typex.M) (Watcher, error)

func Get

func Get(names ...string) Factory

type Opt

type Opt func(*options)

type Response

type Response = types.WatchResp

type Watcher

type Watcher interface {
	Name() string
	Close(ctx context.Context, opts ...Opt)
	Get(ctx context.Context, key string, opts ...Opt) ([]*Response, error)
	GetCallback(ctx context.Context, key string, fn func(resp *Response), opts ...Opt) error
	Watch(ctx context.Context, key string, opts ...Opt) <-chan *Response
	WatchCallback(ctx context.Context, key string, fn func(resp *Response), opts ...Opt)
}

Watcher ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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