diff options
author | Valery Piashchynski <[email protected]> | 2021-02-10 20:00:22 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-02-10 20:00:22 +0300 |
commit | ae3dd0c3672217be0b3fb4042ef650477fba108b (patch) | |
tree | da5b08308e5aff50a102f41e254ee3620d41550e /pkg/pool | |
parent | da64d9fbab7d73e203e7dbbb9503f4d422feaab0 (diff) |
Rewrite container for the workers
Update tests
Diffstat (limited to 'pkg/pool')
-rwxr-xr-x | pkg/pool/static_pool.go | 5 | ||||
-rwxr-xr-x | pkg/pool/static_pool_test.go | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/pkg/pool/static_pool.go b/pkg/pool/static_pool.go index bb68151f..f1b20bb9 100755 --- a/pkg/pool/static_pool.go +++ b/pkg/pool/static_pool.go @@ -130,7 +130,8 @@ func (sp *StaticPool) Workers() (workers []worker.BaseProcess) { } func (sp *StaticPool) RemoveWorker(wb worker.BaseProcess) error { - return sp.ww.Remove(wb) + sp.ww.Remove(wb) + return nil } // Be careful, sync Exec with ExecWithContext @@ -208,6 +209,8 @@ func (sp *StaticPool) stopWorker(w worker.BaseProcess) { func (sp *StaticPool) checkMaxJobs(w worker.BaseProcess) error { const op = errors.Op("static_pool_check_max_jobs") if sp.cfg.MaxJobs != 0 && w.State().NumExecs() >= sp.cfg.MaxJobs { + w.State().Set(worker.StateDestroyed) + sp.ww.Remove(w) err := sp.ww.Allocate() if err != nil { return errors.E(op, err) diff --git a/pkg/pool/static_pool_test.go b/pkg/pool/static_pool_test.go index 4c1c90e5..44f5936c 100755 --- a/pkg/pool/static_pool_test.go +++ b/pkg/pool/static_pool_test.go @@ -148,8 +148,6 @@ func Test_StaticPool_JobError(t *testing.T) { cfg, ) assert.NoError(t, err) - defer p.Destroy(ctx) - assert.NotNil(t, p) res, err := p.Exec(payload.Payload{Body: []byte("hello")}) @@ -163,6 +161,7 @@ func Test_StaticPool_JobError(t *testing.T) { } assert.Contains(t, err.Error(), "hello") + p.Destroy(ctx) } func Test_StaticPool_Broken_Replace(t *testing.T) { |