forked from gojek/heimdall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
34 lines (30 loc) · 1018 Bytes
/
config.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
package heimdall
import (
"github.com/afex/hystrix-go/hystrix"
)
// HystrixConfig is used to pass configurations for Hystrix
type HystrixConfig struct {
commandName string
commandConfig hystrix.CommandConfig
}
// HystrixCommandConfig takes the hystrix config values
type HystrixCommandConfig struct {
Timeout int
MaxConcurrentRequests int
RequestVolumeThreshold int
SleepWindow int
ErrorPercentThreshold int
}
// NewHystrixConfig should be used to give hystrix commandName and config
func NewHystrixConfig(commandName string, commandConfig HystrixCommandConfig) HystrixConfig {
return HystrixConfig{
commandName: commandName,
commandConfig: hystrix.CommandConfig{
Timeout: commandConfig.Timeout,
MaxConcurrentRequests: commandConfig.MaxConcurrentRequests,
RequestVolumeThreshold: commandConfig.RequestVolumeThreshold,
SleepWindow: commandConfig.SleepWindow,
ErrorPercentThreshold: commandConfig.ErrorPercentThreshold,
},
}
}