Add delay between request for input_file

This commit is contained in:
Leonid Bugaev
2013-10-29 20:49:59 +01:00
parent 72952fddd2
commit 95d3676d83
+8
View File
@@ -4,6 +4,7 @@ import (
"encoding/gob"
"log"
"os"
"time"
)
type FileInput struct {
@@ -45,6 +46,8 @@ func (i *FileInput) String() string {
}
func (i *FileInput) emit() {
var lastTime int64
for {
raw := new(RawRequest)
err := i.decoder.Decode(raw)
@@ -53,6 +56,11 @@ func (i *FileInput) emit() {
return
}
if lastTime != 0 {
time.Sleep(time.Duration(raw.Timestamp - lastTime))
lastTime = raw.Timestamp
}
i.data <- raw.Request
}
}