-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathreporter.go
34 lines (27 loc) · 831 Bytes
/
reporter.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
package fault
// Reporter receives events from faults to use for logging, stats, and other custom reporting.
type Reporter interface {
Report(name string, state InjectorState)
}
// NoopReporter is a reporter that does nothing.
type NoopReporter struct{}
// NewNoopReporter returns a new NoopReporter.
func NewNoopReporter() *NoopReporter {
return &NoopReporter{}
}
// Report does nothing.
func (r *NoopReporter) Report(name string, state InjectorState) {}
// ReporterOption configures structs that accept a Reporter.
type ReporterOption interface {
RejectInjectorOption
ErrorInjectorOption
SlowInjectorOption
}
// reporterOption holds our passed in Reporter.
type reporterOption struct {
reporter Reporter
}
// WithReporter sets the Reporter.
func WithReporter(r Reporter) ReporterOption {
return reporterOption{r}
}