diff options
Diffstat (limited to 'stats/count.go')
| -rw-r--r-- | stats/count.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/stats/count.go b/stats/count.go new file mode 100644 index 0000000..e9c87f5 --- /dev/null +++ b/stats/count.go @@ -0,0 +1,33 @@ +package stats + +import "sts2stats/model" + +type Counter interface { + Count(run model.Run) error +} + +var Counters = []Counter{} + +type CountFunc func(run model.Run) error + +type CountFuncWrapper struct { + f CountFunc +} + +func (c CountFuncWrapper) Count(run model.Run) error { + return c.f(run) +} + +func Func(f CountFunc) Counter { + return CountFuncWrapper{f: f} +} + +func Count(run model.Run) error { + for _, c := range Counters { + err := c.Count(run) + if err != nil { + return err + } + } + return nil +} |
