Fix bugs in monitor
This commit is contained in:
parent
3adce58eb2
commit
91f2af91de
@ -128,7 +128,7 @@ func (m *monitor) Watch(service string) error {
|
|||||||
|
|
||||||
func (m *monitor) Stop() error {
|
func (m *monitor) Stop() error {
|
||||||
m.Lock()
|
m.Lock()
|
||||||
defer m.RUnlock()
|
defer m.Unlock()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-m.exit:
|
case <-m.exit:
|
||||||
@ -203,6 +203,7 @@ func newMonitor(opts ...Option) Monitor {
|
|||||||
|
|
||||||
m := &monitor{
|
m := &monitor{
|
||||||
options: options,
|
options: options,
|
||||||
|
exit: make(chan bool),
|
||||||
client: options.Client,
|
client: options.Client,
|
||||||
registry: cache.New(options.Registry),
|
registry: cache.New(options.Registry),
|
||||||
services: make(map[string]*Status),
|
services: make(map[string]*Status),
|
||||||
|
@ -12,8 +12,20 @@ func TestMonitor(t *testing.T) {
|
|||||||
|
|
||||||
for _, service := range services {
|
for _, service := range services {
|
||||||
_, err := m.Status(service)
|
_, err := m.Status(service)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
t.Fatal("expected status error for unknown service")
|
t.Fatal("expected status error for unknown service")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := m.Watch(service); err == nil {
|
||||||
|
t.Fatal("expected watch error for unknown service")
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// 1. start a service
|
||||||
|
// 2. watch service
|
||||||
|
// 3. get service status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stop monitor
|
||||||
|
m.Stop()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user