mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
docker: improve stats names and comments
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user