40 lines
890 B
Go
40 lines
890 B
Go
package proxy_test
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"git.wntrmute.dev/kyle/crossbar/internal/health"
|
|
)
|
|
|
|
// fakeHealth is a hand-set health table that also records MarkDown calls. It lived in the v0
|
|
// proxy_test.go; the v1 given test replaces that file, so recorder_test.go (which still exercises
|
|
// the nil-lease path through proxy.New) needs it here.
|
|
type fakeHealth struct {
|
|
mu sync.Mutex
|
|
st map[string]health.Status
|
|
marked []string
|
|
}
|
|
|
|
func (f *fakeHealth) Get(name string) (health.Status, bool) {
|
|
f.mu.Lock()
|
|
defer f.mu.Unlock()
|
|
s, ok := f.st[name]
|
|
return s, ok
|
|
}
|
|
|
|
func (f *fakeHealth) MarkDown(name, reason string) {
|
|
f.mu.Lock()
|
|
defer f.mu.Unlock()
|
|
f.marked = append(f.marked, name)
|
|
s := f.st[name]
|
|
s.Healthy = false
|
|
s.LastErr = reason
|
|
f.st[name] = s
|
|
}
|
|
|
|
func (f *fakeHealth) markedHosts() []string {
|
|
f.mu.Lock()
|
|
defer f.mu.Unlock()
|
|
return append([]string{}, f.marked...)
|
|
}
|