From 244e59e94f153af82e6c3bd8a6c200a48d3cea60 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Mon, 5 Mar 2018 15:59:04 -0800 Subject: [PATCH] daemon/stats: remove obnoxious types file While a `types.go` file is handly when there are a lot of record types, it is completely obnoxious when used for concrete, utility types with a struct, new function and method set in the same file. This change removes the `types.go` file in favor of the simpler approach. Signed-off-by: Stephen J Day --- daemon/stats/collector.go | 33 ++++++++++++++++++++++++++++++ daemon/stats/types.go | 42 --------------------------------------- 2 files changed, 33 insertions(+), 42 deletions(-) delete mode 100644 daemon/stats/types.go diff --git a/daemon/stats/collector.go b/daemon/stats/collector.go index 39c76128b0..787cff53a1 100644 --- a/daemon/stats/collector.go +++ b/daemon/stats/collector.go @@ -1,6 +1,8 @@ package stats // import "github.com/docker/docker/daemon/stats" import ( + "bufio" + "sync" "time" "github.com/docker/docker/api/types" @@ -9,6 +11,37 @@ import ( "github.com/sirupsen/logrus" ) +// Collector manages and provides container resource stats +type Collector struct { + m sync.Mutex + supervisor supervisor + interval time.Duration + publishers map[*container.Container]*pubsub.Publisher + bufReader *bufio.Reader + + // The following fields are not set on Windows currently. + clockTicksPerSecond uint64 +} + +// NewCollector creates a stats collector that will poll the supervisor with the specified interval +func NewCollector(supervisor supervisor, interval time.Duration) *Collector { + s := &Collector{ + interval: interval, + supervisor: supervisor, + publishers: make(map[*container.Container]*pubsub.Publisher), + bufReader: bufio.NewReaderSize(nil, 128), + } + + platformNewStatsCollector(s) + + return s +} + +type supervisor interface { + // GetContainerStats collects all the stats related to a container + GetContainerStats(container *container.Container) (*types.StatsJSON, error) +} + // Collect registers the container with the collector and adds it to // the event loop for collection on the specified interval returning // a channel for the subscriber to receive on. diff --git a/daemon/stats/types.go b/daemon/stats/types.go deleted file mode 100644 index cdd47d60a6..0000000000 --- a/daemon/stats/types.go +++ /dev/null @@ -1,42 +0,0 @@ -package stats // import "github.com/docker/docker/daemon/stats" - -import ( - "bufio" - "sync" - "time" - - "github.com/docker/docker/api/types" - "github.com/docker/docker/container" - "github.com/docker/docker/pkg/pubsub" -) - -type supervisor interface { - // GetContainerStats collects all the stats related to a container - GetContainerStats(container *container.Container) (*types.StatsJSON, error) -} - -// NewCollector creates a stats collector that will poll the supervisor with the specified interval -func NewCollector(supervisor supervisor, interval time.Duration) *Collector { - s := &Collector{ - interval: interval, - supervisor: supervisor, - publishers: make(map[*container.Container]*pubsub.Publisher), - bufReader: bufio.NewReaderSize(nil, 128), - } - - platformNewStatsCollector(s) - - return s -} - -// Collector manages and provides container resource stats -type Collector struct { - m sync.Mutex - supervisor supervisor - interval time.Duration - publishers map[*container.Container]*pubsub.Publisher - bufReader *bufio.Reader - - // The following fields are not set on Windows currently. - clockTicksPerSecond uint64 -}