refactor dockersource container refresh into channel

This commit is contained in:
Bradley Cicenas
2017-03-05 06:46:41 +00:00
parent 8fb5c5de59
commit 3172f141f9
9 changed files with 85 additions and 100 deletions

View File

@@ -17,14 +17,13 @@ type Container struct {
collector metrics.Collector
}
func NewContainer(id, name string, collector metrics.Collector) *Container {
func NewContainer(id string, collector metrics.Collector) *Container {
return &Container{
Metrics: metrics.NewMetrics(),
Id: id,
Name: name,
Meta: make(map[string]string),
Updates: make(chan [2]string),
Widgets: compact.NewCompact(id, name),
Widgets: compact.NewCompact(id),
collector: collector,
}
}
@@ -41,6 +40,11 @@ func (c *Container) SetMeta(k, v string) {
c.Updates <- [2]string{k, v}
}
func (c *Container) SetName(n string) {
c.Name = n
c.Widgets.Name.Set(n)
}
func (c *Container) SetState(s string) {
c.State = s
c.Widgets.Status.Set(s)