1 Star 0 Fork 0

nqlite/ngossip

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
watcher.go 554 Bytes
一键复制 编辑 原始数据 按行查看 历史
jiaweicheng 提交于 2024-02-16 14:27 . updaate *
package env
import (
"context"
"gitee.com/natsql/ngossip/config"
)
var _ config.Watcher = (*watcher)(nil)
type watcher struct {
ctx context.Context
cancel context.CancelFunc
}
func NewWatcher() (config.Watcher, error) {
ctx, cancel := context.WithCancel(context.Background())
return &watcher{ctx: ctx, cancel: cancel}, nil
}
// Next will be blocked until the Stop method is called
func (w *watcher) Next() ([]*config.KeyValue, error) {
<-w.ctx.Done()
return nil, w.ctx.Err()
}
func (w *watcher) Stop() error {
w.cancel()
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/nqlite/ngossip.git
git@gitee.com:nqlite/ngossip.git
nqlite
ngossip
ngossip
e110283f372f

搜索帮助