diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | config.go | 2 | ||||
-rw-r--r-- | config_test.go | 11 |
3 files changed, 14 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 27dd0d60..3849c9bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) ------------------- @@ -2,6 +2,7 @@ package roadrunner import ( "fmt" + "runtime" "time" ) @@ -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 } diff --git a/config_test.go b/config_test.go index 89cde8f1..e51cb2c4 100644 --- a/config_test.go +++ b/config_test.go @@ -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, |