Refactor emitter.go and fix test accordingly.

This commit is contained in:
Arijit Das
2020-06-06 16:00:43 +05:30
parent 932c894b6b
commit db28858804
17 changed files with 225 additions and 148 deletions
+6 -1
View File
@@ -3,6 +3,7 @@ package main
import (
"log"
"net"
"os"
"time"
"github.com/buger/goreplay/proto"
@@ -52,7 +53,10 @@ func NewRAWInput(address string, engine int, trackResponse bool, expire time.Dur
}
func (i *RAWInput) Read(data []byte) (int, error) {
msg := <-i.data
msg, ok := <-i.data
if !ok {
return 0, os.ErrClosed
}
buf := msg.Bytes()
var header []byte
@@ -109,5 +113,6 @@ func (i *RAWInput) String() string {
func (i *RAWInput) Close() error {
i.listener.Close()
close(i.quit)
close(i.data)
return nil
}