-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathoptions.go
More file actions
54 lines (44 loc) · 1.09 KB
/
Copy pathoptions.go
File metadata and controls
54 lines (44 loc) · 1.09 KB
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
54
package hedge
import "time"
type config struct {
percentile float64
maxHedges int
budgetPercent float64
budgetRPS float64
minDelay time.Duration
warmupRequests int
warmupDelay time.Duration
windowDuration time.Duration
stats **Stats
}
func defaults() config {
return config{
percentile: 0.90,
maxHedges: 1,
budgetPercent: 10.0,
budgetRPS: 100,
minDelay: 1 * time.Millisecond,
warmupRequests: 20,
warmupDelay: 10 * time.Millisecond,
windowDuration: 30 * time.Second,
}
}
type Option func(*config)
func WithPercentile(p float64) Option {
return func(c *config) { c.percentile = p }
}
func WithMaxHedges(n int) Option {
return func(c *config) { c.maxHedges = n }
}
func WithBudgetPercent(pct float64) Option {
return func(c *config) { c.budgetPercent = pct }
}
func WithMinDelay(d time.Duration) Option {
return func(c *config) { c.minDelay = d }
}
func WithStats(s **Stats) Option {
return func(c *config) { c.stats = s }
}
func WithEstimatedRPS(rps float64) Option {
return func(c *config) { c.budgetRPS = rps }
}