prober: refactor probe state into a Probe struct.

Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
David Anderson
2022-03-19 21:39:50 -07:00
committed by Dave Anderson
parent 94aaec5c66
commit a09c30aac2
2 changed files with 117 additions and 112 deletions
+3 -3
View File
@@ -80,10 +80,10 @@ func TestProberRun(t *testing.T) {
)
const startingProbes = 100
cancels := []context.CancelFunc{}
var probes []*Probe
for i := 0; i < startingProbes; i++ {
cancels = append(cancels, p.Run(fmt.Sprintf("probe%d", i), probeInterval, func(context.Context) error {
probes = append(probes, p.Run(fmt.Sprintf("probe%d", i), probeInterval, func(context.Context) error {
mu.Lock()
defer mu.Unlock()
cnt++
@@ -114,7 +114,7 @@ func TestProberRun(t *testing.T) {
keep := startingProbes / 2
for i := keep; i < startingProbes; i++ {
cancels[i]()
probes[i].Close()
}
waitActiveProbes(t, p, keep)