Skip to content

Commit

Permalink
feat: add trend enabled config
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao committed Mar 2, 2023
1 parent d0c8d5b commit 9a55ae0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions internal/app/appconfig/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ type ConfigSpec struct {
// WorkerTrendInterval describes the interval in-between different batches
WorkerTrendInterval time.Duration `required:"true" split_words:"true" default:"6h"`

// WorkerTrendEnabled describes whether to enable the trend worker
WorkerTrendEnabled bool `required:"true" split_words:"true" default:"true"`

// WorkerSeparation describes the separation time in-between different microtasks
WorkerSeparation time.Duration `required:"true" split_words:"true" default:"3s"`

Expand Down
8 changes: 7 additions & 1 deletion internal/workers/calcwkr/calcwkr.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ func Start(conf *appconfig.Config, deps WorkerDeps) {
}
w.checkConfig()
w.doMainCalc(conf.MatrixWorkerSourceCategories)
w.doTrendCalc(conf.MatrixWorkerSourceCategories)
if conf.WorkerTrendEnabled {
w.doTrendCalc(conf.MatrixWorkerSourceCategories)
} else {
log.Info().
Str("evt.name", "worker.calcwkr.trend.disabled").
Msg("worker trend is disabled due to configuration")
}
} else {
log.Info().
Str("evt.name", "worker.calcwkr.disabled").
Expand Down

0 comments on commit 9a55ae0

Please sign in to comment.