diff options
author | Wolfy-J <[email protected]> | 2020-10-26 21:25:33 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2020-10-26 21:25:33 +0300 |
commit | 722584b153c009612ccbaf1fb7a9911f7afae476 (patch) | |
tree | d9fab8f2fbee3737668caf4657affab605fb4146 | |
parent | 6d3bd7d47aa9d08847eecfb241298f323aae05ca (diff) |
- lazy load test
-rwxr-xr-x | pool.go | 6 | ||||
-rwxr-xr-x | static_pool_test.go | 9 |
2 files changed, 4 insertions, 11 deletions
@@ -75,10 +75,8 @@ type Config struct { // worker handle as many tasks as it can. MaxJobs int64 - // Deferred flag enables slower working mode which inits empty worker ahead of every request. Useful to debug - // applications with heavy bootload phase. Do not use at production. It is also keeps pool without any workers - // until first request. - Deferred bool + // HeavyLoad flag creates new fresh worker before every request. + HeavyLoad bool // AllocateTimeout defines for how long pool will be waiting for a worker to // be freed to handle the task. Defaults to 60s. diff --git a/static_pool_test.go b/static_pool_test.go index c9a43f69..ffa39c2f 100755 --- a/static_pool_test.go +++ b/static_pool_test.go @@ -308,7 +308,7 @@ func Test_StaticPool_Debug_Worker(t *testing.T) { func() *exec.Cmd { return exec.Command("php", "tests/client.php", "pid", "pipes") }, NewPipeFactory(), Config{ - Deferred: true, + HeavyLoad: true, NumWorkers: 1, MaxJobs: 1, AllocateTimeout: time.Second, @@ -320,15 +320,10 @@ func Test_StaticPool_Debug_Worker(t *testing.T) { assert.NotNil(t, p) - assert.Len(t, p.Workers(), 0) + assert.Len(t, p.Workers(), 1) var lastPID string res, _ := p.Exec(Payload{Body: []byte("hello")}) - - assert.Len(t, p.Workers(), 1) - - lastPID = strconv.Itoa(int(p.Workers()[0].Pid())) - res, _ = p.Exec(Payload{Body: []byte("hello")}) assert.NotEqual(t, lastPID, string(res.Body)) for i := 0; i < 10; i++ { |