Add statistics fetcher interface

This commit is contained in:
Gregory Eremin 2015-10-24 18:17:24 +03:00
parent 1550495bf9
commit 2ebd972a34
2 changed files with 19 additions and 4 deletions

View File

@ -13,7 +13,7 @@ import (
type Satan struct { type Satan struct {
SubscribeFunc SubscribeFunc SubscribeFunc SubscribeFunc
Publisher Publisher Publisher Publisher
Statistics Statistics Statistics StatsPublisher
daemons []Daemon daemons []Daemon
queue chan *task queue chan *task
@ -44,11 +44,26 @@ type Publisher interface {
Close() Close()
} }
type Statistics interface { type StatsManager interface {
StatsPublisher
StatsFetcher
}
type StatsPublisher interface {
Add(name string, dur time.Duration) Add(name string, dur time.Duration)
Error(name string) Error(name string)
} }
type StatsFetcher interface {
Processed(name string) int64
Errors(name string) int64
Min(name string) int64
Max(name string) int64
P95(name string) float64
Mean(name string) float64
StdDev(name string) float64
}
type task struct { type task struct {
daemon Daemon daemon Daemon
actor Actor actor Actor

View File

@ -7,10 +7,10 @@ import (
) )
type Group struct { type Group struct {
backends []satan.Statistics backends []satan.StatsPublisher
} }
func NewGroup(backends ...satan.Statistics) *Group { func NewGroup(backends ...satan.StatsPublisher) *Group {
return &Group{ return &Group{
backends: backends, backends: backends,
} }