-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
capturer.go
224 lines (184 loc) · 5.58 KB
/
capturer.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
package runn
import (
"net/http"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)
type Capturer interface {
CaptureStart(trs Trails, bookPath, desc string)
CaptureResult(trs Trails, result *RunResult)
CaptureEnd(trs Trails, bookPath, desc string)
CaptureResultByStep(trs Trails, result *RunResult)
CaptureHTTPRequest(name string, req *http.Request)
CaptureHTTPResponse(name string, res *http.Response)
CaptureGRPCStart(name string, typ GRPCType, service, method string)
CaptureGRPCRequestHeaders(h map[string][]string)
CaptureGRPCRequestMessage(m map[string]any)
CaptureGRPCResponseStatus(*status.Status)
CaptureGRPCResponseHeaders(h map[string][]string)
CaptureGRPCResponseMessage(m map[string]any)
CaptureGRPCResponseTrailers(t map[string][]string)
CaptureGRPCClientClose()
CaptureGRPCEnd(name string, typ GRPCType, service, method string)
CaptureCDPStart(name string)
CaptureCDPAction(a CDPAction)
CaptureCDPResponse(a CDPAction, res map[string]any)
CaptureCDPEnd(name string)
CaptureSSHCommand(command string)
CaptureSSHStdout(stdout string)
CaptureSSHStderr(stderr string)
CaptureDBStatement(name string, stmt string)
CaptureDBResponse(name string, res *DBResponse)
CaptureExecCommand(command, shell string, background bool)
CaptureExecStdin(stdin string)
CaptureExecStdout(stdout string)
CaptureExecStderr(stderr string)
SetCurrentTrails(trs Trails)
Errs() error
}
type capturers []Capturer
func (cs capturers) captureStart(trs Trails, bookPath, desc string) { //nostyle:recvtype
for _, c := range cs {
c.CaptureStart(trs, bookPath, desc)
}
}
func (cs capturers) captureResult(trs Trails, result *RunResult) { //nostyle:recvtype
for _, c := range cs {
c.CaptureResult(trs, result)
}
}
func (cs capturers) captureEnd(trs Trails, bookPath, desc string) { //nostyle:recvtype
for _, c := range cs {
c.CaptureEnd(trs, bookPath, desc)
}
}
func (cs capturers) captureResultByStep(trs Trails, result *RunResult) { //nostyle:recvtype
for _, c := range cs {
c.CaptureResultByStep(trs, result)
}
}
func (cs capturers) captureHTTPRequest(name string, req *http.Request) { //nostyle:recvtype
for _, c := range cs {
c.CaptureHTTPRequest(name, req)
}
}
func (cs capturers) captureHTTPResponse(name string, res *http.Response) { //nostyle:recvtype
for _, c := range cs {
c.CaptureHTTPResponse(name, res)
}
}
func (cs capturers) captureGRPCStart(name string, typ GRPCType, service, method string) { //nostyle:recvtype
for _, c := range cs {
c.CaptureGRPCStart(name, typ, service, method)
}
}
func (cs capturers) captureGRPCRequestHeaders(h metadata.MD) { //nostyle:recvtype
for _, c := range cs {
c.CaptureGRPCRequestHeaders(h)
}
}
func (cs capturers) captureGRPCRequestMessage(m map[string]any) { //nostyle:recvtype
for _, c := range cs {
c.CaptureGRPCRequestMessage(m)
}
}
func (cs capturers) captureGRPCResponseStatus(s *status.Status) { //nostyle:recvtype
for _, c := range cs {
c.CaptureGRPCResponseStatus(s)
}
}
func (cs capturers) captureGRPCResponseHeaders(h metadata.MD) { //nostyle:recvtype
for _, c := range cs {
c.CaptureGRPCResponseHeaders(h)
}
}
func (cs capturers) captureGRPCResponseMessage(m map[string]any) { //nostyle:recvtype
for _, c := range cs {
c.CaptureGRPCResponseMessage(m)
}
}
func (cs capturers) captureGRPCResponseTrailers(t metadata.MD) { //nostyle:recvtype
for _, c := range cs {
c.CaptureGRPCResponseTrailers(t)
}
}
func (cs capturers) captureGRPCClientClose() { //nostyle:recvtype
for _, c := range cs {
c.CaptureGRPCClientClose()
}
}
func (cs capturers) captureGRPCEnd(name string, typ GRPCType, service, method string) { //nostyle:recvtype
for _, c := range cs {
c.CaptureGRPCEnd(name, typ, service, method)
}
}
func (cs capturers) captureCDPStart(name string) { //nostyle:recvtype
for _, c := range cs {
c.CaptureCDPStart(name)
}
}
func (cs capturers) captureCDPAction(a CDPAction) { //nostyle:recvtype
for _, c := range cs {
c.CaptureCDPAction(a)
}
}
func (cs capturers) captureCDPResponse(a CDPAction, res map[string]any) { //nostyle:recvtype
for _, c := range cs {
c.CaptureCDPResponse(a, res)
}
}
func (cs capturers) captureCDPEnd(name string) { //nostyle:recvtype
for _, c := range cs {
c.CaptureCDPEnd(name)
}
}
func (cs capturers) captureSSHCommand(command string) { //nostyle:recvtype
for _, c := range cs {
c.CaptureSSHCommand(command)
}
}
func (cs capturers) captureSSHStdout(stdout string) { //nostyle:recvtype
for _, c := range cs {
c.CaptureSSHStdout(stdout)
}
}
func (cs capturers) captureSSHStderr(stderr string) { //nostyle:recvtype
for _, c := range cs {
c.CaptureSSHStderr(stderr)
}
}
func (cs capturers) captureDBStatement(name string, stmt string) { //nostyle:recvtype
for _, c := range cs {
c.CaptureDBStatement(name, stmt)
}
}
func (cs capturers) captureDBResponse(name string, res *DBResponse) { //nostyle:recvtype
for _, c := range cs {
c.CaptureDBResponse(name, res)
}
}
func (cs capturers) captureExecCommand(command, shell string, background bool) { //nostyle:recvtype
for _, c := range cs {
c.CaptureExecCommand(command, shell, background)
}
}
func (cs capturers) captureExecStdin(stdin string) { //nostyle:recvtype
for _, c := range cs {
c.CaptureExecStdin(stdin)
}
}
func (cs capturers) captureExecStdout(stdout string) { //nostyle:recvtype
for _, c := range cs {
c.CaptureExecStdout(stdout)
}
}
func (cs capturers) captureExecStderr(stderr string) { //nostyle:recvtype
for _, c := range cs {
c.CaptureExecStderr(stderr)
}
}
func (cs capturers) setCurrentTrails(trs Trails) { //nostyle:recvtype
for _, c := range cs {
c.SetCurrentTrails(trs)
}
}