2019-01-14 15:27:25 +00:00
|
|
|
package memory
|
2016-04-26 18:32:43 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
2020-01-30 14:39:00 +03:00
|
|
|
"github.com/micro/go-micro/v2/registry"
|
2016-04-26 18:32:43 +01:00
|
|
|
)
|
|
|
|
|
2019-01-14 15:27:25 +00:00
|
|
|
type memoryWatcher struct {
|
2016-04-26 18:32:43 +01:00
|
|
|
exit chan bool
|
2018-02-19 17:12:37 +00:00
|
|
|
opts registry.WatchOptions
|
2016-04-26 18:32:43 +01:00
|
|
|
}
|
|
|
|
|
2019-01-14 15:27:25 +00:00
|
|
|
func (m *memoryWatcher) Next() (*registry.Result, error) {
|
2016-04-26 18:32:43 +01:00
|
|
|
// not implement so we just block until exit
|
2019-12-03 22:59:44 +03:00
|
|
|
<-m.exit
|
|
|
|
return nil, errors.New("watcher stopped")
|
2016-04-26 18:32:43 +01:00
|
|
|
}
|
|
|
|
|
2019-01-14 15:27:25 +00:00
|
|
|
func (m *memoryWatcher) Stop() {
|
2016-04-26 18:32:43 +01:00
|
|
|
select {
|
|
|
|
case <-m.exit:
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
close(m.exit)
|
|
|
|
}
|
|
|
|
}
|