micro/config/source/mucp/watcher.go

28 lines
560 B
Go
Raw Normal View History

2020-01-16 19:10:15 +03:00
package mucp
import (
"github.com/micro/go-micro/config/source"
proto "github.com/micro/go-micro/config/source/mucp/proto"
)
type watcher struct {
stream proto.Source_WatchService
}
func newWatcher(stream proto.Source_WatchService) (source.Watcher, error) {
return &watcher{stream: stream}, nil
}
func (w *watcher) Next() (*source.ChangeSet, error) {
var rsp proto.WatchResponse
err := w.stream.RecvMsg(&rsp)
if err != nil {
return nil, err
}
return toChangeSet(rsp.ChangeSet), nil
}
func (w *watcher) Stop() error {
return w.stream.Close()
}