-
Notifications
You must be signed in to change notification settings - Fork 4
/
check.go
39 lines (32 loc) · 1010 Bytes
/
check.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package doctor
import (
"context"
"projectforge.dev/projectforge/app/lib/telemetry"
"projectforge.dev/projectforge/app/util"
)
type (
CheckFn func(ctx context.Context, r *Result, logger util.Logger) *Result
SolveFn func(ctx context.Context, r *Result, logger util.Logger) *Result
)
type Check struct {
Key string `json:"key"`
Section string `json:"section"`
Title string `json:"title"`
Summary string `json:"summary,omitempty"`
URL string `json:"url,omitempty"`
UsedBy string `json:"usedBy,omitempty"`
Modules []string `json:"modules,omitempty"`
Fn CheckFn `json:"-"`
Solve SolveFn `json:"-"`
}
func (c *Check) Check(ctx context.Context, logger util.Logger) *Result {
_, span, logger := telemetry.StartSpan(ctx, "doctor:check:"+c.Key, logger)
defer span.Complete()
r := NewResult(c, c.Key, c.Title, c.Summary)
timer := util.TimerStart()
r = c.Fn(ctx, r, logger)
r.Duration = timer.End()
r = c.Solve(ctx, r, logger)
return r
}
type Checks = []*Check