diff --git a/drivers/docker/stats.go b/drivers/docker/stats.go index a04089978..f02bd1492 100644 --- a/drivers/docker/stats.go +++ b/drivers/docker/stats.go @@ -32,9 +32,9 @@ type usageSender struct { mu sync.Mutex } -// newDestChPair returns a destCh that supports concurrent sending and closing, -// and the receiver end of the chan. -func newDestChPair() (*usageSender, <-chan *structs.TaskResourceUsage) { +// newStatsChanPipe returns a chan wrapped in a struct that supports concurrent +// sending and closing, and the receiver end of the chan. +func newStatsChanPipe() (*usageSender, <-chan *structs.TaskResourceUsage) { destCh := make(chan *cstructs.TaskResourceUsage, 1) return &usageSender{ destCh: destCh, @@ -82,7 +82,7 @@ func (h *taskHandle) Stats(ctx context.Context, interval time.Duration) (<-chan default: } - destCh, recvCh := newDestChPair() + destCh, recvCh := newStatsChanPipe() go h.collectStats(ctx, destCh, interval) return recvCh, nil } diff --git a/drivers/docker/stats_test.go b/drivers/docker/stats_test.go index e1ed3ba62..f9c290c3c 100644 --- a/drivers/docker/stats_test.go +++ b/drivers/docker/stats_test.go @@ -17,7 +17,7 @@ func TestDriver_DockerStatsCollector(t *testing.T) { require := require.New(t) src := make(chan *docker.Stats) defer close(src) - dst, recvCh := newDestChPair() + dst, recvCh := newStatsChanPipe() defer dst.close() stats := &docker.Stats{} stats.CPUStats.ThrottlingData.Periods = 10 @@ -72,7 +72,7 @@ func TestDriver_DockerUsageSender(t *testing.T) { // sample payload res := &cstructs.TaskResourceUsage{} - destCh, recvCh := newDestChPair() + destCh, recvCh := newStatsChanPipe() // Sending should never fail destCh.send(res)