This commit is contained in:
cubixle
2021-07-25 20:52:56 +01:00
parent 645ff9d698
commit 2ddeeea267
7 changed files with 140 additions and 10 deletions
+27 -8
View File
@@ -1,22 +1,41 @@
package l1
import "time"
import (
"time"
)
// F defines the function type for runners.
type F func(target string) error
// Runner
type Runner struct {
MaxConnections int
Timeout int
RunTime time.Duration
MaxConnections int
MaxParrellConnections int
Timeout time.Duration
RunTime time.Duration
RunFunc F
Target string
}
func NewRunner(opts ...Opt) {
func NewRunner(opts ...Opt) (*Runner, error) {
r := &Runner{
RunTime: 60 * time.Second,
RunTime: 60 * time.Second,
Timeout: 30 * time.Second,
MaxParrellConnections: 10,
MaxConnections: 10,
}
for _, o := range opts {
o(r)
}
if r.Target == "" {
return nil, ErrNoTarget
}
return r, nil
}
// F defines the function type for runners.
type F func(url string) error
func (r *Runner) SetOpt(o Opt) {
o(r)
}