mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Add delay between request for input_file
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user