1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-05-13 21:16:43 +02:00
2020-12-26 15:32:45 +00:00

29 lines
545 B
Go

package grpc
import (
"github.com/micro/go-micro/v2/config/source"
proto "github.com/micro/go-micro/plugins/config/source/grpc/v2/proto"
)
type watcher struct {
stream proto.Source_WatchClient
}
func newWatcher(stream proto.Source_WatchClient) (*watcher, error) {
return &watcher{
stream: stream,
}, nil
}
func (w *watcher) Next() (*source.ChangeSet, error) {
rsp, err := w.stream.Recv()
if err != nil {
return nil, err
}
return toChangeSet(rsp.ChangeSet), nil
}
func (w *watcher) Stop() error {
return w.stream.CloseSend()
}