diff options
author | Wolfy-J <[email protected]> | 2020-10-26 21:28:11 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2020-10-26 21:28:11 +0300 |
commit | 9d2de5e46110c07eceb87dcfde3af9b6a6c4a76c (patch) | |
tree | e17593c4320f004b5eb7b1321a5f6bcb538b34cc | |
parent | 722584b153c009612ccbaf1fb7a9911f7afae476 (diff) |
- lazy load test
-rwxr-xr-x | static_pool.go | 4 | ||||
-rwxr-xr-x | static_pool_test.go | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/static_pool.go b/static_pool.go index 4ecbdd41..2905742b 100755 --- a/static_pool.go +++ b/static_pool.go @@ -43,6 +43,10 @@ type StaticPool struct { func NewPool(ctx context.Context, cmd func() *exec.Cmd, factory Factory, cfg Config) (Pool, error) { cfg.InitDefaults() + if cfg.HeavyLoad { + cfg.NumWorkers = 0 + } + p := &StaticPool{ cfg: cfg, cmd: cmd, diff --git a/static_pool_test.go b/static_pool_test.go index ffa39c2f..a3b19bad 100755 --- a/static_pool_test.go +++ b/static_pool_test.go @@ -320,12 +320,15 @@ func Test_StaticPool_Debug_Worker(t *testing.T) { assert.NotNil(t, p) - assert.Len(t, p.Workers(), 1) + assert.Len(t, p.Workers(), 0) var lastPID string res, _ := p.Exec(Payload{Body: []byte("hello")}) assert.NotEqual(t, lastPID, string(res.Body)) + // todo: necessary? + assert.Len(t, p.Workers(), 0) + for i := 0; i < 10; i++ { lastPID = strconv.Itoa(int(p.Workers()[0].Pid())) res, err := p.Exec(Payload{Body: []byte("hello")}) |