expvarmon/data.go

32 lines
544 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-05-01 21:49:19 +08:00
Vars []string
2015-04-25 20:54:17 +08:00
LastTimestamp time.Time
}
2015-05-01 21:49:19 +08:00
// NewUIData inits and return new data object.
func NewUIData(vars []string) *UIData {
return &UIData{
Vars: vars,
}
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
}