summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2019-02-14 15:08:06 +0300
committerWolfy-J <[email protected]>2019-02-14 15:08:06 +0300
commit77cb14cd7d6b0773b20065e8e5a3f95d1c5c96f8 (patch)
tree15dfc710a601cdcd28149c4a7af1326178924089
parent278e16855669a5112a9fa627a5db0fedd62266ec (diff)
default value for numWorkers
-rw-r--r--CHANGELOG.md1
-rw-r--r--config.go2
-rw-r--r--config_test.go11
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)
-------------------
diff --git a/config.go b/config.go
index 23f1afc8..649ad9f4 100644
--- a/config.go
+++ b/config.go
@@ -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,