mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
refactor dockersource container refresh into channel
This commit is contained in:
10
container.go
10
container.go
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user