watcher

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

README

watcher

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Name = "watcher"
View Source
var Prefix = "/watchers"

Functions

func KeyToDot

func KeyToDot(prefix string) string

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

func Register

func Register(name string, w Factory)

func Watch

func Watch(name string, h CallBack)

Types

type CallBack

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

type Cfg

type Cfg struct {
	Prefix   string   `json:"prefix"`
	Driver   string   `json:"driver"`
	Projects []string `json:"projects"`
}

func GetDefaultCfg

func GetDefaultCfg() Cfg

type Factory

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

type Opt

type Opt func(*Opts)

type Opts

type Opts struct{}

type Response

type Response struct {
	Event    string
	Key      string
	Value    []byte
	Revision int64
}

func (*Response) Decode

func (t *Response) Decode(val interface{}) (gErr error)

func (*Response) OnDelete

func (t *Response) OnDelete(fn func())

func (*Response) OnPut

func (t *Response) OnPut(fn func())

type Watcher

type Watcher interface {
	Watch(ctx context.Context, key string, opts ...Opt) <-chan *Response
	Name() string
}

Watcher ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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