expvarmon/data.go

30 lines
506 B
Go
Raw Normal View History

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