Add statistics groups
This commit is contained in:
parent
0e1fbbe729
commit
bfa1575d79
4
satan.go
4
satan.go
|
@ -45,8 +45,8 @@ type Publisher interface {
|
|||
}
|
||||
|
||||
type Statistics interface {
|
||||
Add(daemonName string, dur time.Duration)
|
||||
Error(daemonName string)
|
||||
Add(name string, dur time.Duration)
|
||||
Error(name string)
|
||||
}
|
||||
|
||||
type task struct {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package stats
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/localhots/satan"
|
||||
)
|
||||
|
||||
type Group struct {
|
||||
backends []satan.Statistics
|
||||
}
|
||||
|
||||
func NewGroup(backends ...satan.Statistics) *Group {
|
||||
return &Group{
|
||||
backends: backends,
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Group) Add(name string, dur time.Duration) {
|
||||
for _, b := range g.backends {
|
||||
b.Add(name, dur)
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Group) Error(name string) {
|
||||
for _, b := range g.backends {
|
||||
b.Error(name)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue