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

Function ReadFromCaptureFile

input_file_test.go:326–360  ·  view source on GitHub ↗
(captureFile *os.File, count int, callback writeCallback)

Source from the content-addressed store, hash-verified

324}
325
326func ReadFromCaptureFile(captureFile *os.File, count int, callback writeCallback) (err error) {
327 wg := new(sync.WaitGroup)
328
329 input := NewFileInput(captureFile.Name(), false, 100, 0, false)
330 output := NewTestOutput(func(msg *Message) {
331 callback(msg)
332 wg.Done()
333 })
334
335 plugins := &InOutPlugins{
336 Inputs: []PluginReader{input},
337 Outputs: []PluginWriter{output},
338 }
339 plugins.All = append(plugins.All, input, output)
340
341 wg.Add(count)
342 emitter := NewEmitter()
343 go emitter.Start(plugins, Settings.Middleware)
344
345 done := make(chan int, 1)
346 go func() {
347 wg.Wait()
348 done <- 1
349 }()
350
351 select {
352 case <-done:
353 break
354 case <-time.After(2 * time.Second):
355 err = errors.New("Timed out")
356 }
357 emitter.Close()
358 return
359
360}

Callers 3

TestInputFileWithGETFunction · 0.85

Calls 5

StartMethod · 0.95
CloseMethod · 0.95
NewFileInputFunction · 0.85
NewTestOutputFunction · 0.85
NewEmitterFunction · 0.85

Tested by

no test coverage detected