diff options
| author | ewy <ewy0@protonmail.com> | 2026-05-22 16:54:49 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-05-22 16:54:49 +0200 |
| commit | 007e2de369f9fc26da3237646de14f2af5052ee8 (patch) | |
| tree | f81557385628fc93f1ef9616b8bc75a304f9d740 /stats/count.go | |
initial commit
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 +} |
