mirror of
https://github.com/cubixle/l1.git
synced 2026-04-30 08:28:45 +01:00
updates
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user