MCPcopy
hub / github.com/probelabs/goreplay / Start

Method Start

emitter.go:26–59  ·  view source on GitHub ↗

Start initialize loop for sending data from inputs to outputs

(plugins *InOutPlugins, middlewareCmd string)

Source from the content-addressed store, hash-verified

24
25// Start initialize loop for sending data from inputs to outputs
26func (e *Emitter) Start(plugins *InOutPlugins, middlewareCmd string) {
27 if Settings.CopyBufferSize < 1 {
28 Settings.CopyBufferSize = 5 << 20
29 }
30 e.plugins = plugins
31
32 if middlewareCmd != "" {
33 middleware := NewMiddleware(middlewareCmd)
34
35 for _, in := range plugins.Inputs {
36 middleware.ReadFrom(in)
37 }
38
39 e.plugins.Inputs = append(e.plugins.Inputs, middleware)
40 e.plugins.All = append(e.plugins.All, middleware)
41 e.Add(1)
42 go func() {
43 defer e.Done()
44 if err := CopyMulty(middleware, plugins.Outputs...); err != nil {
45 Debug(2, fmt.Sprintf("[EMITTER] error during copy: %q", err))
46 }
47 }()
48 } else {
49 for _, in := range plugins.Inputs {
50 e.Add(1)
51 go func(in PluginReader) {
52 defer e.Done()
53 if err := CopyMulty(in, plugins.Outputs...); err != nil {
54 Debug(2, fmt.Sprintf("[EMITTER] error during copy: %q", err))
55 }
56 }(in)
57 }
58 }
59}
60
61// Close closes all the goroutine and waits for it to finish.
62func (e *Emitter) Close() {

Callers 15

TestMiddlewareEarlyCloseFunction · 0.95
TestTokenMiddlewareFunction · 0.95
mainFunction · 0.95
TestHTTPInputFunction · 0.95
CreateCaptureFileFunction · 0.95
ReadFromCaptureFileFunction · 0.95
TestFileOutputFunction · 0.95
TestTCPOutputFunction · 0.95
BenchmarkTCPOutputFunction · 0.95
TestOutputLimiterFunction · 0.95

Calls 4

ReadFromMethod · 0.95
NewMiddlewareFunction · 0.85
CopyMultyFunction · 0.85
DebugFunction · 0.70

Tested by 15

TestMiddlewareEarlyCloseFunction · 0.76
TestTokenMiddlewareFunction · 0.76
TestHTTPInputFunction · 0.76
CreateCaptureFileFunction · 0.76
ReadFromCaptureFileFunction · 0.76
TestFileOutputFunction · 0.76
TestTCPOutputFunction · 0.76
BenchmarkTCPOutputFunction · 0.76
TestOutputLimiterFunction · 0.76
TestInputLimiterFunction · 0.76