watcher

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2021 License: Apache-2.0 Imports: 14 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 Init

func Init(projects ...string) (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, callback Handler)

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"`
}

func DefaultCfg

func DefaultCfg() Cfg

func (Cfg) Build

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

type Factory

type Factory = func(cfg types.M) (Watcher, error)

func Get

func Get(names ...string) Factory

type Handler

type Handler = func(name string, r *types.WatchResp) error

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