Skip to content

Commit 8eb16b4

Browse files
Ethereal-Oimbajin
andauthored
refactor(vermeer): make startChan's size configurable (#328)
* refactor(startChan): make startChan's size configurable * Update vermeer/config/master.ini --------- Co-authored-by: imbajin <[email protected]>
1 parent 1765fd9 commit 8eb16b4

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

vermeer/apps/master/bl/scheduler_bl.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ package bl
1919

2020
import (
2121
"errors"
22+
"strconv"
2223
"time"
24+
"vermeer/apps/common"
2325
"vermeer/apps/master/schedules"
2426
"vermeer/apps/structure"
2527

@@ -36,7 +38,16 @@ type ScheduleBl struct {
3638
}
3739

3840
func (s *ScheduleBl) Init() {
39-
startChan := make(chan *structure.TaskInfo, 10) // TODO: make configurable
41+
const defaultChanSizeConfig = "10"
42+
chanSize := common.GetConfigDefault("start_chan_size", defaultChanSizeConfig).(string)
43+
// Convert string to int
44+
chanSizeInt, err := strconv.Atoi(chanSize)
45+
if err != nil {
46+
logrus.Errorf("failed to convert start_chan_size to int: %v", err)
47+
logrus.Infof("using default start_chan_size: %s", defaultChanSizeConfig)
48+
chanSizeInt, _ = strconv.Atoi(defaultChanSizeConfig)
49+
}
50+
startChan := make(chan *structure.TaskInfo, chanSizeInt)
4051
s.startChan = startChan
4152
s.spaceQueue = (&schedules.SpaceQueue{}).Init()
4253
s.broker = (&schedules.Broker{}).Init()

vermeer/config/master.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ run_mode=master
2323
task_strategy=1
2424
task_parallel_num=1
2525
auth=none
26-
auth_token_factor=1234
26+
auth_token_factor=1234
27+
start_chan_size=10

0 commit comments

Comments
 (0)