Skip to content

Commit

Permalink
default value for numWorkers
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy-j committed Feb 14, 2019
1 parent 278e168 commit 77cb14c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@ v1.3.5 (14.02.2019)
* **json** - output as json
- new console flag `w` to specify work dir
- added ability to work without config file when at least one `overwrite` option has been specified
- pool config now sets `numWorkers` equal to number of cores by default (this section can be omitted now)

v1.3.4 (02.02.2019)
-------------------
Expand Down
2 changes: 2 additions & 0 deletions config.go
Expand Up @@ -2,6 +2,7 @@ package roadrunner

import (
"fmt"
"runtime"
"time"
)

Expand Down Expand Up @@ -29,6 +30,7 @@ type Config struct {
func (cfg *Config) InitDefaults() error {
cfg.AllocateTimeout = time.Minute
cfg.DestroyTimeout = time.Minute
cfg.NumWorkers = int64(runtime.NumCPU())

return nil
}
Expand Down
11 changes: 11 additions & 0 deletions config_test.go
Expand Up @@ -17,6 +17,17 @@ func Test_NumWorkers(t *testing.T) {
assert.Equal(t, "pool.NumWorkers must be set", err.Error())
}

func Test_NumWorkers_Default(t *testing.T) {
cfg := Config{
AllocateTimeout: time.Second,
DestroyTimeout: time.Second * 10,
}

assert.NoError(t, cfg.InitDefaults())
err := cfg.Valid()
assert.Nil(t, err)
}

func Test_AllocateTimeout(t *testing.T) {
cfg := Config{
NumWorkers: 10,
Expand Down

0 comments on commit 77cb14c

Please sign in to comment.