-
Notifications
You must be signed in to change notification settings - Fork 8
/
nop_emitter.go
68 lines (44 loc) · 1.9 KB
/
nop_emitter.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package cff
import (
"context"
"time"
)
// NopEmitter is a cff emitter that does not do anything.
func NopEmitter() Emitter {
// We implement the interface on the pointer receiver to avoid
// allocations when the emitter is used. Conversion from pointer to
// interface requires no allocs, but conversion from value to
// interface does.
return &nopEmitter{}
}
// NopFlowEmitter is a Flow emitter that does not do anything.
func NopFlowEmitter() FlowEmitter {
return &nopEmitter{}
}
// NopParallelEmitter is a Parallel emitter that does not do anything.
func NopParallelEmitter() ParallelEmitter {
return &nopEmitter{}
}
// NopTaskEmitter is a Task emitter that does not do anything.
func NopTaskEmitter() TaskEmitter {
return &nopEmitter{}
}
type nopEmitter struct{}
func (e *nopEmitter) FlowInit(*FlowInfo) FlowEmitter { return e }
func (*nopEmitter) FlowSuccess(context.Context) {}
func (*nopEmitter) FlowError(context.Context, error) {}
func (*nopEmitter) FlowDone(context.Context, time.Duration) {}
func (e *nopEmitter) ParallelInit(*ParallelInfo) ParallelEmitter { return e }
func (*nopEmitter) ParallelSuccess(context.Context) {}
func (*nopEmitter) ParallelError(context.Context, error) {}
func (*nopEmitter) ParallelDone(context.Context, time.Duration) {}
func (e *nopEmitter) TaskInit(*TaskInfo, *DirectiveInfo) TaskEmitter { return e }
func (*nopEmitter) TaskSuccess(context.Context) {}
func (*nopEmitter) TaskError(context.Context, error) {}
func (*nopEmitter) TaskErrorRecovered(context.Context, error) {}
func (*nopEmitter) TaskSkipped(context.Context, error) {}
func (*nopEmitter) TaskPanic(context.Context, interface{}) {}
func (*nopEmitter) TaskPanicRecovered(context.Context, interface{}) {}
func (*nopEmitter) TaskDone(context.Context, time.Duration) {}
func (e *nopEmitter) SchedulerInit(*SchedulerInfo) SchedulerEmitter { return e }
func (e *nopEmitter) EmitScheduler(SchedulerState) {}