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

29 lines
531 B
Go
Raw Normal View History

2020-12-26 15:32:45 +00:00
package grpc
import (
2021-10-12 12:55:53 +01:00
"go-micro.dev/v4/config/source"
2021-10-13 13:31:23 +01:00
proto "github.com/asim/go-micro/plugins/config/source/grpc/v4/proto"
2020-12-26 15:32:45 +00:00
)
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()
}