Created
April 24, 2022 22:45
-
-
Save cbweixin/c137b15414192e800f0c5f1d9066a231 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ParamSet struct { | |
Caller lib.Caller | |
TimeoutNS time.Duration | |
LPS uint32 | |
DurationNS time.Duration | |
ResultCh chan *lib.CallResult | |
} | |
func (pset *ParamSet) Check() error { | |
var errMsgs []string | |
if pset.Caller == nil { | |
errMsgs = append(errMsgs, "Invalid caller!") | |
} | |
if pset.LPS == 0 { | |
errMsgs = append(errMsgs, "Invalid lps(load per second)!") | |
} | |
if pset.TimeoutNS == 0 { | |
errMsgs = append(errMsgs, "Invalid timeoutNS!") | |
} | |
if pset.DurationNS == 0 { | |
errMsgs = append(errMsgs, "Invalid durationNS!") | |
} | |
if pset.ResultCh == nil { | |
errMsgs = append(errMsgs, "Invalid result channel!") | |
} | |
var buf bytes.Buffer | |
buf.WriteString("Checking the parameters...") | |
if errMsgs != nil { | |
errMsg := strings.Join(errMsgs, " ") | |
buf.WriteString(fmt.Sprintf("NOT passed! (%s)", errMsg)) | |
logger.Infoln(buf.String()) | |
return errors.New(errMsg) | |
} | |
buf.WriteString( | |
fmt.Sprintf("Passed. (timeoutNS=%s, lps=%d,durationNS=%s)", | |
pset.TimeoutNS, pset.LPS, pset.DurationNS)) | |
logger.Infoln(buf.String()) | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment