-
Notifications
You must be signed in to change notification settings - Fork 0
/
generatorParams.go
50 lines (42 loc) · 1.25 KB
/
generatorParams.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
package main
import (
"errors"
"go.uber.org/zap"
"load-generator/helper"
"load-generator/lib"
"strings"
"time"
)
type NewLoadGeneratorParams struct {
Caller lib.Caller
PPS uint64
ProcessingDurationNS time.Duration
TimeoutNS time.Duration
ResultChan chan *lib.CallResult
}
func (receiver *NewLoadGeneratorParams) Check() error {
helper.Logger.Info("Start Checking NewLoadGeneratorParams...")
var errMsgs []string
if receiver.Caller == nil {
errMsgs = append(errMsgs, "Invalid caller!")
}
if receiver.ResultChan == nil {
errMsgs = append(errMsgs, "Invalid resultChan!")
}
if receiver.PPS == 0 {
errMsgs = append(errMsgs, "Invalid pps!")
}
if receiver.ProcessingDurationNS == 0 {
errMsgs = append(errMsgs, "Invalid processingDurationNS!")
}
if receiver.TimeoutNS == 0 {
errMsgs = append(errMsgs, "Invalid timeoutNS!")
}
if len(errMsgs) > 0 {
errMsg := strings.Join(errMsgs, " ")
helper.Logger.Info("Didn't Pass Params Check", zap.String("err", errMsg))
return errors.New(errMsg)
}
helper.Logger.Info("Passed Params Check", zap.Uint64("pps", receiver.PPS), zap.Duration("timeoutNS", receiver.TimeoutNS), zap.Duration("processingDurationNS", receiver.ProcessingDurationNS))
return nil
}