rename mucp source directory to service
This commit is contained in:
27
config/source/service/watcher.go
Normal file
27
config/source/service/watcher.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/micro/go-micro/config/source"
|
||||
proto "github.com/micro/go-micro/config/source/service/proto"
|
||||
)
|
||||
|
||||
type watcher struct {
|
||||
stream proto.Service_WatchService
|
||||
}
|
||||
|
||||
func newWatcher(stream proto.Service_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()
|
||||
}
|
Reference in New Issue
Block a user