watcher

package
v0.0.0-...-d66ce5c Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Create  = "Create"
	Remove  = "Remove"
	Modify  = "Modify"
	Unknown = "Unknown"
)

Variables

This section is empty.

Functions

func Add

func Add(path string, n Notifier) error

func Load

func Load(dir, name string) ([]byte, error)

func Register

func Register(dir string, profile UserProfile) error

Register 函数注册配置文件到观察列表中,每次配置文件发送变动时,通知profile进行更新

Types

type Notifier

type Notifier interface {
	Notify(event string, path string) error
}

type UserProfile

type UserProfile interface {
	Name() string
	Modify(data []byte) error
}

UserProfile 为用户配置结构的接口,当以函数Name的返回值为名称的配置文件被创建或者修改时, Modify函数会被调用,触发配置结构内容的更改 Modify函数必须有事务支持,即当Modify函数返回error时,配置结构的内容不应被改变 TODO 是否应该支持Name会动态变化的?

Jump to

Keyboard shortcuts

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