(captureFile *os.File, count int, callback writeCallback)
| 324 | } |
| 325 | |
| 326 | func 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 | } |
no test coverage detected