docker: improve stats names and comments

This commit is contained in:
Michael Schurter
2019-04-02 09:18:38 -07:00
parent 82d3c43e31
commit 855a08810c
2 changed files with 6 additions and 6 deletions

View File

@@ -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
}

View File

@@ -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)