forked from rookie-ninja/rk-query
-
Notifications
You must be signed in to change notification settings - Fork 0
/
event_noop.go
195 lines (155 loc) · 4.77 KB
/
event_noop.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// Copyright (c) 2021 rookie-ninja
//
// Use of this source code is governed by an Apache-style
// license that can be found in the LICENSE file.
package rkquery
import (
"go.uber.org/zap"
"time"
)
type eventNoop struct{}
// ************* Time *************
// SetStartTime sets start timer of current event. This can be overridden by user.
// We keep this function open in order to mock event during unit test.
func (event *eventNoop) SetStartTime(time.Time) {
// Noop
}
// GetStartTime returns start time of current event data.
func (event *eventNoop) GetStartTime() time.Time {
return time.Now()
}
// SetEndTime sets end timer of current event. This can be overridden by user.
// We keep this function open in order to mock event during unit test.
func (event *eventNoop) SetEndTime(time.Time) {
// Noop
}
// GetEndTime returns end time of current event data.
func (event *eventNoop) GetEndTime() time.Time {
return time.Now()
}
// ************* Payload *************
// AddPayloads function add payload as zap.Field.
// Payload could be anything with RPC requests or user event such as http request param.
func (event *eventNoop) AddPayloads(...zap.Field) {
// Noop
}
// ListPayloads will lists payloads.
func (event *eventNoop) ListPayloads() []zap.Field {
return []zap.Field{}
}
// ************* Identity *************
// GetEventId returns event id of current event.
func (event *eventNoop) GetEventId() string {
return ""
}
// SetEventId sets event id of current event.
// A new event id would be created while event data was created from EventFactory.
// User could override event id with this function.
func (event *eventNoop) SetEventId(string) {
// Noop
}
// GetTraceId returns trace id of current event.
func (event *eventNoop) GetTraceId() string {
return ""
}
// SetTraceId set trace id of current event.
func (event *eventNoop) SetTraceId(string) {
// Noop
}
// GetRequestId returns request id of current event.
func (event *eventNoop) GetRequestId() string {
return ""
}
// SetRequestId set request id of current event.
func (event *eventNoop) SetRequestId(string) {
// Noop
}
// ************* Error *************
// AddErr function adds an error into event which could be printed with error.Error() function.
func (event *eventNoop) AddErr(error) {
// Noop
}
// GetErrCount returns error count.
// We will use value of error.Error() as the key.
func (event *eventNoop) GetErrCount(error) int64 {
return 0
}
// ************* Event *************
// GetOperation returns operation of current event.
func (event *eventNoop) GetOperation() string {
return ""
}
// SetOperation sets operation of current event.
func (event *eventNoop) SetOperation(string) {
// Noop
}
// GetRemoteAddr returns remote address of current event.
func (event *eventNoop) GetRemoteAddr() string {
return ""
}
// SetRemoteAddr sets remote address of current event, mainly used in RPC calls.
// Default value of <localhost> would be assigned while creating event via EventFactory.
func (event *eventNoop) SetRemoteAddr(string) {
// Noop
}
// GetResCode returns response code of current event.
// Mainly used in RPC calls.
func (event *eventNoop) GetResCode() string {
return ""
}
// SetResCode sets response code of current event.
func (event *eventNoop) SetResCode(string) {
// Noop
}
// GetEventStatus returns event status of current event.
// Available event status as bellow:
// 1: NotStarted
// 2: InProgress
// 3: Ended
func (event *eventNoop) GetEventStatus() eventStatus {
return NotStarted
}
// StartTimer starts timer of current sub event.
func (event *eventNoop) StartTimer(string) {
// Noop
}
// EndTimer ends timer of current sub event.
func (event *eventNoop) EndTimer(string) {
// Noop
}
// UpdateTimerMs updates timer of current sub event with time elapsed in milli seconds.
func (event *eventNoop) UpdateTimerMs(string, int64) {
// Noop
}
// UpdateTimerMsWithSample updates timer of current sub event with time elapsed in milli seconds and sample.
func (event *eventNoop) UpdateTimerMsWithSample(string, int64, int64) {
// Noop
}
// GetTimeElapsedMs returns timer elapsed in milli seconds.
func (event *eventNoop) GetTimeElapsedMs(string) int64 {
return 0
}
// GetValueFromPair returns value with key in pairs.
func (event *eventNoop) GetValueFromPair(string) string {
return ""
}
// AddPair adds value with key in pairs.
func (event *eventNoop) AddPair(string, string) {
// Noop
}
// GetCounter returns counter of current event.
func (event *eventNoop) GetCounter(string) int64 {
return 0
}
// SetCounter sets counter of current event.
func (event *eventNoop) SetCounter(string, int64) {
// Noop
}
// IncCounter increases counter of current event.
func (event *eventNoop) IncCounter(string, int64) {
// Noop
}
// Finish sets event status and flush to logger.
func (event *eventNoop) Finish() {
// Noop
}