From 007e2de369f9fc26da3237646de14f2af5052ee8 Mon Sep 17 00:00:00 2001 From: ewy Date: Fri, 22 May 2026 16:54:49 +0200 Subject: initial commit --- stats/count.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 stats/count.go (limited to 'stats/count.go') 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 +} -- cgit v1.3.1