Make heartbeater goroutine a monitor goroutine for process info.

This commit is contained in:
Ken Hibino
2020-02-15 21:59:06 -08:00
parent 0856ef32e0
commit 2bcaea52ce
7 changed files with 65 additions and 82 deletions

View File

@@ -34,8 +34,9 @@ func TestHeartbeater(t *testing.T) {
for _, tc := range tests {
h.FlushDB(t, r)
pi := base.NewProcessInfo(tc.host, tc.pid, tc.concurrency, tc.queues, false)
hb := newHeartbeater(rdbClient, pi, tc.interval)
stateCh := make(chan string)
workerCh := make(chan int)
hb := newHeartbeater(rdbClient, tc.host, tc.pid, tc.concurrency, tc.queues, false, tc.interval, stateCh, workerCh)
want := &base.ProcessInfo{
Host: tc.host,
@@ -64,7 +65,7 @@ func TestHeartbeater(t *testing.T) {
}
// state change
pi.SetState("stopped")
stateCh <- "stopped"
// allow for heartbeater to write to redis
time.Sleep(tc.interval * 2)