-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstats.go
74 lines (55 loc) · 1.47 KB
/
stats.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
69
70
71
72
73
74
package subee
import (
"context"
"time"
)
// StatsHandler is the interface for related stats handling
type StatsHandler interface {
TagProcess(context.Context, Tag) context.Context
HandleProcess(context.Context, Stats)
}
// Tag is tag information.
type Tag interface {
isTag()
}
// Stats is stats information about receive/consume.
type Stats interface {
isStats()
}
// NopStatsHandler is no-op StatsHandler
type NopStatsHandler struct{}
// TagProcess returns context without doing anythig
func (*NopStatsHandler) TagProcess(ctx context.Context, t Tag) context.Context {
return ctx
}
// HandleProcess do nothing
func (*NopStatsHandler) HandleProcess(context.Context, Stats) {}
// BeginTag is tag for an receive/consume process starts.
type BeginTag struct{}
func (*BeginTag) isTag() {}
// End contains stats when an receive/consume process ends.
type End struct {
MsgCount int
BeginTime time.Time
EndTime time.Time
}
func (*End) isStats() {}
// ConsumeBeginTag is tag for consumption start.
type ConsumeBeginTag struct{}
func (*ConsumeBeginTag) isTag() {}
// ConsumeEnd contains stats when consume end.
type ConsumeEnd struct {
BeginTime time.Time
EndTime time.Time
Error error
}
func (pb *ConsumeEnd) isStats() {}
// EnqueueTag is tag for enqueue in channel.
type EnqueueTag struct{}
func (*EnqueueTag) isTag() {}
// Dequeue contains stats when dequeue in channel.
type Dequeue struct {
BeginTime time.Time
EndTime time.Time
}
func (*Dequeue) isStats() {}