Merge branch 'master' into pro-merge

This commit is contained in:
Urban Ishimwe
2020-06-16 22:43:08 +02:00
21 changed files with 308 additions and 140 deletions
+11 -1
View File
@@ -3,21 +3,26 @@ package main
import (
"crypto/rand"
"encoding/base64"
"errors"
"fmt"
"time"
)
// ErrorStopped is the error returned when the go routines reading the input is stopped.
var ErrorStopped = errors.New("reading stopped")
// TestInput used for testing purpose, it allows emitting requests on demand
type TestInput struct {
data chan []byte
skipHeader bool
stop chan bool // Channel used only to indicate goroutine should shutdown
}
// NewTestInput constructor for TestInput
func NewTestInput() (i *TestInput) {
i = new(TestInput)
i.data = make(chan []byte, 100)
i.stop = make(chan bool)
return
}
@@ -40,6 +45,11 @@ func (i *TestInput) Read(data []byte) (int, error) {
}
}
func (i *TestInput) Close() error {
close(i.stop)
return nil
}
func (i *TestInput) EmitBytes(data []byte) {
i.data <- data
}