2015-04-25 20:54:17 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
// Data represents data to be passed to UI.
|
|
|
|
type Data struct {
|
|
|
|
Services Services
|
2015-04-26 03:46:16 +08:00
|
|
|
Total int
|
2015-04-25 20:54:17 +08:00
|
|
|
TotalMemory *Stack
|
|
|
|
LastTimestamp time.Time
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewData inits and return new data object.
|
|
|
|
func NewData() *Data {
|
|
|
|
return &Data{
|
|
|
|
TotalMemory: NewStack(140),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FindService returns existing service by port.
|
|
|
|
func (d *Data) FindService(port string) *Service {
|
|
|
|
if d.Services == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
for _, service := range d.Services {
|
|
|
|
if service.Port == port {
|
|
|
|
return service
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|