Skip to content

Commit c918968

Browse files
author
Andrei Skomorkhov
authored
Merge pull request #44 from OlgaMinyaeva/master
move to config fix_node timeout value
2 parents bd7e282 + 137cab6 commit c918968

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

config/config.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ type Config struct {
2020

2121
// Grid general settings
2222
type Grid struct {
23-
ClientType string `json:"client_type"`
24-
Port int `json:"port"`
25-
StrategyList []Strategy `json:"strategy_list"`
26-
BusyNodeDuration string `json:"busy_node_duration"` // duration string format ex. 12m, see time.ParseDuration()
23+
ClientType string `json:"client_type"`
24+
Port int `json:"port"`
25+
StrategyList []Strategy `json:"strategy_list"`
26+
// duration string format ex. 12m, see time.ParseDuration()
27+
BusyNodeDuration string `json:"busy_node_duration"`
2728
// todo: выпилить и сделать равным дедлайну http запроса
28-
ReservedDuration string `json:"reserved_node_duration"` // duration string format ex. 12m, see time.ParseDuration()
29+
ReservedDuration string `json:"reserved_node_duration"`
30+
FixNodeTimeout string `json:"fix_node_timeout,omitempty"`
2931
}
3032

3133
// Strategy - Describes the algorithm of node selection.
@@ -63,9 +65,19 @@ type Statsd struct {
6365
CapabilitiesList []metrics.CapabilitiesSelector `json:"selectors"`
6466
}
6567

66-
// New - Constructor of config.
68+
// New - Constructor of config with default values
6769
func New() *Config {
68-
return &Config{}
70+
return &Config{Logger: Logger{Level: "debug"},
71+
DB: DB{Implementation: "local"},
72+
Grid: Grid{
73+
ClientType: "selenium",
74+
Port: 4444,
75+
StrategyList: []Strategy{{Type: "persistent"}},
76+
ReservedDuration: "5m",
77+
BusyNodeDuration: "15m",
78+
FixNodeTimeout: "5m",
79+
},
80+
}
6981
}
7082

7183
// LoadFromFile - config loader from json file.

main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ func main() {
4444
if err != nil {
4545
log.Fatal("Invalid value grid.reserved_node_duration in config")
4646
}
47+
fixNodeDuration, err := time.ParseDuration(cfg.Grid.FixNodeTimeout)
48+
if err != nil {
49+
log.Fatal("Invalid value grid.fix_node_timeout in config")
50+
}
4751
storageFactory, err := invokeStorageFactory(*cfg)
4852
if err != nil {
4953
log.Fatalf("Can't invoke storage factory, %s", err)
@@ -80,7 +84,7 @@ func main() {
8084
go func() {
8185
for {
8286
poolInstance.FixNodeStatuses()
83-
time.Sleep(time.Minute * 5) // todo: move to config
87+
time.Sleep(fixNodeDuration)
8488
}
8589
}()
8690

0 commit comments

Comments
 (0)