Mock watcher that just blocks
This commit is contained in:
parent
decb70b97c
commit
f7c57fd4f4
@ -88,7 +88,7 @@ func (m *mockRegistry) Deregister(s *registry.Service) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockRegistry) Watch() (registry.Watcher, error) {
|
func (m *mockRegistry) Watch() (registry.Watcher, error) {
|
||||||
return nil, nil
|
return &mockWatcher{exit: make(chan bool)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockRegistry) String() string {
|
func (m *mockRegistry) String() string {
|
||||||
|
28
registry/mock/mock_watcher.go
Normal file
28
registry/mock/mock_watcher.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package mock
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/micro/go-micro/registry"
|
||||||
|
)
|
||||||
|
|
||||||
|
type mockWatcher struct {
|
||||||
|
exit chan bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *mockWatcher) Next() (*registry.Result, error) {
|
||||||
|
// not implement so we just block until exit
|
||||||
|
select {
|
||||||
|
case <-m.exit:
|
||||||
|
return nil, errors.New("watcher stopped")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *mockWatcher) Stop() {
|
||||||
|
select {
|
||||||
|
case <-m.exit:
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
close(m.exit)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user