feat: optimize field name of ProbeConfig (#2391)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
fd4422a044
commit
730dcbf2bc
|
|
@ -298,7 +298,7 @@ type NetworkConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetworkTopologyConfig struct {
|
type NetworkTopologyConfig struct {
|
||||||
// Enable network topology service, including probe, network topology collection and synchronization service.
|
// Enable network topology service, including probe, network topology collection.
|
||||||
Enable bool `yaml:"enable" mapstructure:"enable"`
|
Enable bool `yaml:"enable" mapstructure:"enable"`
|
||||||
|
|
||||||
// CollectInterval is the interval of collecting network topology.
|
// CollectInterval is the interval of collecting network topology.
|
||||||
|
|
@ -309,14 +309,14 @@ type NetworkTopologyConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProbeConfig struct {
|
type ProbeConfig struct {
|
||||||
// QueueLength is the length of probe queue in directed graph.
|
// QueueLength is the length of probe queue.
|
||||||
QueueLength int `mapstructure:"queueLength" yaml:"queueLength"`
|
QueueLength int `mapstructure:"queueLength" yaml:"queueLength"`
|
||||||
|
|
||||||
// SyncInterval is the interval of synchronizing host's probes.
|
// Interval is the interval of probing hosts.
|
||||||
SyncInterval time.Duration `mapstructure:"syncInterval" yaml:"syncInterval"`
|
Interval time.Duration `mapstructure:"interval" yaml:"interval"`
|
||||||
|
|
||||||
// SyncCount is the number of probing hosts.
|
// Count is the number of probing hosts.
|
||||||
SyncCount int `mapstructure:"syncCount" yaml:"syncCount"`
|
Count int `mapstructure:"count" yaml:"count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TrainerConfig struct {
|
type TrainerConfig struct {
|
||||||
|
|
@ -409,9 +409,9 @@ func New() *Config {
|
||||||
Enable: true,
|
Enable: true,
|
||||||
CollectInterval: DefaultNetworkTopologyCollectInterval,
|
CollectInterval: DefaultNetworkTopologyCollectInterval,
|
||||||
Probe: ProbeConfig{
|
Probe: ProbeConfig{
|
||||||
QueueLength: DefaultProbeQueueLength,
|
QueueLength: DefaultProbeQueueLength,
|
||||||
SyncInterval: DefaultProbeSyncInterval,
|
Interval: DefaultProbeInterval,
|
||||||
SyncCount: DefaultProbeSyncCount,
|
Count: DefaultProbeCount,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Trainer: TrainerConfig{
|
Trainer: TrainerConfig{
|
||||||
|
|
@ -579,12 +579,12 @@ func (cfg *Config) Validate() error {
|
||||||
return errors.New("probe requires parameter queueLength")
|
return errors.New("probe requires parameter queueLength")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.NetworkTopology.Probe.SyncInterval <= 0 {
|
if cfg.NetworkTopology.Probe.Interval <= 0 {
|
||||||
return errors.New("probe requires parameter syncInterval")
|
return errors.New("probe requires parameter interval")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.NetworkTopology.Probe.SyncCount <= 0 {
|
if cfg.NetworkTopology.Probe.Count <= 0 {
|
||||||
return errors.New("probe requires parameter syncCount")
|
return errors.New("probe requires parameter count")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.Trainer.Enable {
|
if cfg.Trainer.Enable {
|
||||||
|
|
|
||||||
|
|
@ -164,9 +164,9 @@ func TestConfig_Load(t *testing.T) {
|
||||||
Enable: true,
|
Enable: true,
|
||||||
CollectInterval: 60 * time.Second,
|
CollectInterval: 60 * time.Second,
|
||||||
Probe: ProbeConfig{
|
Probe: ProbeConfig{
|
||||||
QueueLength: 5,
|
QueueLength: 5,
|
||||||
SyncInterval: 30 * time.Second,
|
Interval: 30 * time.Second,
|
||||||
SyncCount: 10,
|
Count: 10,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Trainer: TrainerConfig{
|
Trainer: TrainerConfig{
|
||||||
|
|
@ -711,31 +711,31 @@ func TestConfig_Validate(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "probe requires parameter SyncInterval",
|
name: "probe requires parameter interval",
|
||||||
config: New(),
|
config: New(),
|
||||||
mock: func(cfg *Config) {
|
mock: func(cfg *Config) {
|
||||||
cfg.Manager = mockManagerConfig
|
cfg.Manager = mockManagerConfig
|
||||||
cfg.Database.Redis = mockRedisConfig
|
cfg.Database.Redis = mockRedisConfig
|
||||||
cfg.Job = mockJobConfig
|
cfg.Job = mockJobConfig
|
||||||
cfg.NetworkTopology.Probe.SyncInterval = 0
|
cfg.NetworkTopology.Probe.Interval = 0
|
||||||
},
|
},
|
||||||
expect: func(t *testing.T, err error) {
|
expect: func(t *testing.T, err error) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
assert.EqualError(err, "probe requires parameter syncInterval")
|
assert.EqualError(err, "probe requires parameter interval")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "probe requires parameter SyncCount",
|
name: "probe requires parameter count",
|
||||||
config: New(),
|
config: New(),
|
||||||
mock: func(cfg *Config) {
|
mock: func(cfg *Config) {
|
||||||
cfg.Manager = mockManagerConfig
|
cfg.Manager = mockManagerConfig
|
||||||
cfg.Database.Redis = mockRedisConfig
|
cfg.Database.Redis = mockRedisConfig
|
||||||
cfg.Job = mockJobConfig
|
cfg.Job = mockJobConfig
|
||||||
cfg.NetworkTopology.Probe.SyncCount = 0
|
cfg.NetworkTopology.Probe.Count = 0
|
||||||
},
|
},
|
||||||
expect: func(t *testing.T, err error) {
|
expect: func(t *testing.T, err error) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
assert.EqualError(err, "probe requires parameter syncCount")
|
assert.EqualError(err, "probe requires parameter count")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -163,20 +163,17 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// TODO(fcgxz2003): The default setting needs to be changed after testing.
|
|
||||||
// DefaultNetworkTopologyCollectInterval is the default interval of collecting network topology.
|
// DefaultNetworkTopologyCollectInterval is the default interval of collecting network topology.
|
||||||
DefaultNetworkTopologyCollectInterval = 60 * time.Second
|
DefaultNetworkTopologyCollectInterval = 2 * time.Hour
|
||||||
|
|
||||||
// DefaultProbeQueueLength is the default length of probe queue in directed graph.
|
// DefaultProbeQueueLength is the default length of probe queue.
|
||||||
DefaultProbeQueueLength = 5
|
DefaultProbeQueueLength = 5
|
||||||
|
|
||||||
// TODO(fcgxz2003): The default setting needs to be changed after testing.
|
// DefaultProbeInterval is the default interval of probing host.
|
||||||
// DefaultProbeSyncInterval is the default interval of synchronizing host's probes.
|
DefaultProbeInterval = 15 * time.Minute
|
||||||
DefaultProbeSyncInterval = 30 * time.Second
|
|
||||||
|
|
||||||
// TODO(fcgxz2003): The default setting needs to be changed after testing.
|
// DefaultProbeCount is the default number of probing hosts.
|
||||||
// DefaultProbeSyncCount is the default number of probing hosts.
|
DefaultProbeCount = 10
|
||||||
DefaultProbeSyncCount = 10
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,8 @@ networkTopology:
|
||||||
collectInterval: 60s
|
collectInterval: 60s
|
||||||
probe:
|
probe:
|
||||||
queueLength: 5
|
queueLength: 5
|
||||||
syncInterval: 30s
|
interval: 30s
|
||||||
syncCount: 10
|
count: 10
|
||||||
|
|
||||||
trainer:
|
trainer:
|
||||||
enable: false
|
enable: false
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue