feat: backoff config initial func
This commit is contained in:
22
internal/config/backoff.go
Normal file
22
internal/config/backoff.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/Mmx233/BackoffCli/backoff"
|
||||
"time"
|
||||
)
|
||||
|
||||
var BackoffConfig backoff.Conf
|
||||
|
||||
func initBackoff() {
|
||||
setting := Settings.Guardian.Backoff
|
||||
BackoffConfig = backoff.Conf{
|
||||
Logger: Logger,
|
||||
DisableRecovery: true,
|
||||
InitialDuration: time.Duration(setting.InitialDuration) * time.Second,
|
||||
MaxDuration: time.Duration(setting.MaxDuration) * time.Second,
|
||||
MaxRetry: setting.MaxRetries,
|
||||
ExponentFactor: int(setting.ExponentFactor),
|
||||
InterConstFactor: time.Duration(setting.InterConstFactor) * time.Second,
|
||||
OuterConstFactor: time.Duration(setting.OuterConstFactor) * time.Second,
|
||||
}
|
||||
}
|
||||
@@ -66,4 +66,5 @@ func init() {
|
||||
}
|
||||
|
||||
initLog()
|
||||
initBackoff()
|
||||
}
|
||||
|
||||
@@ -8,8 +8,19 @@ import (
|
||||
|
||||
type (
|
||||
GuardianConf struct {
|
||||
Enable bool `json:"enable" yaml:"enable"`
|
||||
Duration uint `json:"duration" yaml:"duration"`
|
||||
Enable bool `json:"enable" yaml:"enable"`
|
||||
Duration uint `json:"duration" yaml:"duration"`
|
||||
Backoff BackoffConf `json:"backoff" yaml:"backoff"`
|
||||
}
|
||||
|
||||
BackoffConf struct {
|
||||
MaxRetries uint `json:"max_retries" yaml:"max_retries"`
|
||||
InitialDuration uint `json:"initial_duration" yaml:"initial_duration"`
|
||||
MaxDuration uint `json:"max_duration" yaml:"max_duration"`
|
||||
|
||||
ExponentFactor uint `json:"exponent_factor" yaml:"exponent_factor"`
|
||||
InterConstFactor uint `json:"inter_const_factor" yaml:"inter_const_factor"`
|
||||
OuterConstFactor uint `json:"outer_const_factor" yaml:"outer_const_factor"`
|
||||
}
|
||||
|
||||
BasicConf struct {
|
||||
|
||||
Reference in New Issue
Block a user