Skip to content

Commit

Permalink
feat: control number of workers from config
Browse files Browse the repository at this point in the history
  • Loading branch information
pnicto committed Apr 10, 2024
1 parent 181f635 commit 0e46486
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Config struct {
DownloadLocation string
Token string
TempDirLocation string
NumWorkers int
Slides bool
}

Expand All @@ -41,6 +42,9 @@ func parseConfig(configLocation string) *Config {
config.TempDirLocation = "./temp"
}

if config.NumWorkers == 0 {
config.NumWorkers = 5
}

return &config
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func main() {
log.Fatalln("Could not create temp dir")
}

const numWorkers = 10
numWorkers := config.NumWorkers
playlistJobs := make(chan ParsedPlaylist, numWorkers)

var joinWg sync.WaitGroup
Expand Down
3 changes: 2 additions & 1 deletion sample.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"views": "both",
"downloadLocation": "./downloads",
"tempDirLocation": "./.temp",
"slides": false
"slides": false,
"numWorkers": 5
}

0 comments on commit 0e46486

Please sign in to comment.