feat: optimize field name of ProbeConfig (#2391)

Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
Gaius 2023-05-26 14:14:51 +08:00
parent fd4422a044
commit 730dcbf2bc
No known key found for this signature in database
GPG Key ID: 8B4E5D1290FA2FFB
4 changed files with 30 additions and 33 deletions

View File

@ -298,7 +298,7 @@ type NetworkConfig 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"`
// CollectInterval is the interval of collecting network topology.
@ -309,14 +309,14 @@ type NetworkTopologyConfig 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"`
// SyncInterval is the interval of synchronizing host's probes.
SyncInterval time.Duration `mapstructure:"syncInterval" yaml:"syncInterval"`
// Interval is the interval of probing hosts.
Interval time.Duration `mapstructure:"interval" yaml:"interval"`
// SyncCount is the number of probing hosts.
SyncCount int `mapstructure:"syncCount" yaml:"syncCount"`
// Count is the number of probing hosts.
Count int `mapstructure:"count" yaml:"count"`
}
type TrainerConfig struct {
@ -410,8 +410,8 @@ func New() *Config {
CollectInterval: DefaultNetworkTopologyCollectInterval,
Probe: ProbeConfig{
QueueLength: DefaultProbeQueueLength,
SyncInterval: DefaultProbeSyncInterval,
SyncCount: DefaultProbeSyncCount,
Interval: DefaultProbeInterval,
Count: DefaultProbeCount,
},
},
Trainer: TrainerConfig{
@ -579,12 +579,12 @@ func (cfg *Config) Validate() error {
return errors.New("probe requires parameter queueLength")
}
if cfg.NetworkTopology.Probe.SyncInterval <= 0 {
return errors.New("probe requires parameter syncInterval")
if cfg.NetworkTopology.Probe.Interval <= 0 {
return errors.New("probe requires parameter interval")
}
if cfg.NetworkTopology.Probe.SyncCount <= 0 {
return errors.New("probe requires parameter syncCount")
if cfg.NetworkTopology.Probe.Count <= 0 {
return errors.New("probe requires parameter count")
}
if cfg.Trainer.Enable {

View File

@ -165,8 +165,8 @@ func TestConfig_Load(t *testing.T) {
CollectInterval: 60 * time.Second,
Probe: ProbeConfig{
QueueLength: 5,
SyncInterval: 30 * time.Second,
SyncCount: 10,
Interval: 30 * time.Second,
Count: 10,
},
},
Trainer: TrainerConfig{
@ -711,31 +711,31 @@ func TestConfig_Validate(t *testing.T) {
},
},
{
name: "probe requires parameter SyncInterval",
name: "probe requires parameter interval",
config: New(),
mock: func(cfg *Config) {
cfg.Manager = mockManagerConfig
cfg.Database.Redis = mockRedisConfig
cfg.Job = mockJobConfig
cfg.NetworkTopology.Probe.SyncInterval = 0
cfg.NetworkTopology.Probe.Interval = 0
},
expect: func(t *testing.T, err error) {
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(),
mock: func(cfg *Config) {
cfg.Manager = mockManagerConfig
cfg.Database.Redis = mockRedisConfig
cfg.Job = mockJobConfig
cfg.NetworkTopology.Probe.SyncCount = 0
cfg.NetworkTopology.Probe.Count = 0
},
expect: func(t *testing.T, err error) {
assert := assert.New(t)
assert.EqualError(err, "probe requires parameter syncCount")
assert.EqualError(err, "probe requires parameter count")
},
},
{

View File

@ -163,20 +163,17 @@ const (
)
const (
// TODO(fcgxz2003): The default setting needs to be changed after testing.
// 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
// TODO(fcgxz2003): The default setting needs to be changed after testing.
// DefaultProbeSyncInterval is the default interval of synchronizing host's probes.
DefaultProbeSyncInterval = 30 * time.Second
// DefaultProbeInterval is the default interval of probing host.
DefaultProbeInterval = 15 * time.Minute
// TODO(fcgxz2003): The default setting needs to be changed after testing.
// DefaultProbeSyncCount is the default number of probing hosts.
DefaultProbeSyncCount = 10
// DefaultProbeCount is the default number of probing hosts.
DefaultProbeCount = 10
)
const (

View File

@ -87,8 +87,8 @@ networkTopology:
collectInterval: 60s
probe:
queueLength: 5
syncInterval: 30s
syncCount: 10
interval: 30s
count: 10
trainer:
enable: false