add config
This commit is contained in:
parent
9cb3417986
commit
1880429e73
|
|
@ -81,6 +81,9 @@ func New() *Config {
|
||||||
HostGCInterval: DefaultSchedulerHostGCInterval,
|
HostGCInterval: DefaultSchedulerHostGCInterval,
|
||||||
HostTTL: DefaultSchedulerHostTTL,
|
HostTTL: DefaultSchedulerHostTTL,
|
||||||
},
|
},
|
||||||
|
Cpu: DefaultCpu,
|
||||||
|
RefreshMode: false,
|
||||||
|
RefreshModelInterval: DefaultRefreshModelInterval,
|
||||||
},
|
},
|
||||||
DynConfig: &DynConfig{
|
DynConfig: &DynConfig{
|
||||||
RefreshInterval: DefaultDynConfigRefreshInterval,
|
RefreshInterval: DefaultDynConfigRefreshInterval,
|
||||||
|
|
@ -172,6 +175,14 @@ func (cfg *Config) Validate() error {
|
||||||
return errors.New("scheduler requires parameter taskTTL")
|
return errors.New("scheduler requires parameter taskTTL")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cfg.Scheduler.Cpu <= 0 {
|
||||||
|
return errors.New("scheduler requires parameter cpu")
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.Scheduler.RefreshMode && cfg.Scheduler.RefreshModelInterval <= 0 {
|
||||||
|
return errors.New("scheduler requires parameter RefreshModelInterval")
|
||||||
|
}
|
||||||
|
|
||||||
if cfg.DynConfig.RefreshInterval <= 0 {
|
if cfg.DynConfig.RefreshInterval <= 0 {
|
||||||
return errors.New("dynconfig requires parameter refreshInterval")
|
return errors.New("dynconfig requires parameter refreshInterval")
|
||||||
}
|
}
|
||||||
|
|
@ -284,6 +295,15 @@ type SchedulerConfig struct {
|
||||||
|
|
||||||
// Task and peer gc configuration.
|
// Task and peer gc configuration.
|
||||||
GC *GCConfig `yaml:"gc" mapstructure:"gc"`
|
GC *GCConfig `yaml:"gc" mapstructure:"gc"`
|
||||||
|
|
||||||
|
// Cpu Limit
|
||||||
|
Cpu int `yaml:"cpu" mapstructure:"cpu"`
|
||||||
|
|
||||||
|
// Enable refresh mode
|
||||||
|
RefreshMode bool `yaml:"refreshMode" mapstructure:"refreshMode"`
|
||||||
|
|
||||||
|
// Update model interval
|
||||||
|
RefreshModelInterval time.Duration `yaml:"refreshModelInterval" mapstructure:"refreshModelInterval"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GCConfig struct {
|
type GCConfig struct {
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,12 @@ const (
|
||||||
|
|
||||||
// DefaultSchedulerHostTTL is default ttl for host.
|
// DefaultSchedulerHostTTL is default ttl for host.
|
||||||
DefaultSchedulerHostTTL = 48 * time.Hour
|
DefaultSchedulerHostTTL = 48 * time.Hour
|
||||||
|
|
||||||
|
// DefaultCPU is default cpu usage
|
||||||
|
DefaultCpu = 1
|
||||||
|
|
||||||
|
// DefaultRefreshModelInterval is model refresh interval
|
||||||
|
DefaultRefreshModelInterval = 168 * time.Hour
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue