-
Notifications
You must be signed in to change notification settings - Fork 26
/
output_binary.go
53 lines (42 loc) · 1.57 KB
/
output_binary.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//go:build !pro
package goreplay
import (
"errors"
"time"
"github.com/buger/goreplay/internal/size"
)
var _ PluginWriter = (*BinaryOutput)(nil)
// BinaryOutputConfig struct for holding binary output configuration
type BinaryOutputConfig struct {
Workers int `json:"output-binary-workers"`
Timeout time.Duration `json:"output-binary-timeout"`
BufferSize size.Size `json:"output-tcp-response-buffer"`
Debug bool `json:"output-binary-debug"`
TrackResponses bool `json:"output-binary-track-response"`
}
// BinaryOutput plugin manage pool of workers which send request to replayed server
// By default workers pool is dynamic and starts with 10 workers
// You can specify fixed number of workers using `--output-tcp-workers`
type BinaryOutput struct {
address string
}
// NewBinaryOutput constructor for BinaryOutput
// Initialize workers
func NewBinaryOutput(address string, config *BinaryOutputConfig) PluginReadWriter {
return &BinaryOutput{address: address}
}
// PluginWrite writes a message to this plugin
func (o *BinaryOutput) PluginWrite(msg *Message) (n int, err error) {
return 0, errors.New("binary output is only available in PRO version")
}
// PluginRead reads a message from this plugin
func (o *BinaryOutput) PluginRead() (*Message, error) {
return nil, errors.New("binary output is only available in PRO version")
}
func (o *BinaryOutput) String() string {
return "Binary output: " + o.address + " (PRO version required)"
}
// Close closes this plugin for reading
func (o *BinaryOutput) Close() error {
return nil
}