summaryrefslogtreecommitdiff
path: root/plugins/http/plugin.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-02-11 14:06:10 +0300
committerGitHub <[email protected]>2021-02-11 14:06:10 +0300
commit8f6cafdc0948a5ea13bf9a811b576aa4b3ef7e4a (patch)
tree92727c3ff8087597bac65eee2c26c9484c98be7f /plugins/http/plugin.go
parent7978c59f0ed286912bfcaec81b76e54532b1a9bf (diff)
parent509abc76a0f7b88678de67843ca79d9052ad8dd6 (diff)
Merge pull request #530 from spiral/release_stabilizationv2.0.0-RC.1
stabilization(RC): rc stabilization
Diffstat (limited to 'plugins/http/plugin.go')
-rw-r--r--plugins/http/plugin.go35
1 files changed, 16 insertions, 19 deletions
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go
index 3672f5ac..bab03edc 100644
--- a/plugins/http/plugin.go
+++ b/plugins/http/plugin.go
@@ -102,19 +102,6 @@ func (s *Plugin) Init(cfg config.Configurer, log logger.Logger, server server.Se
}
s.cfg.Env[RR_MODE] = "http"
-
- s.pool, err = server.NewWorkerPool(context.Background(), pool.Config{
- Debug: s.cfg.Pool.Debug,
- NumWorkers: s.cfg.Pool.NumWorkers,
- MaxJobs: s.cfg.Pool.MaxJobs,
- AllocateTimeout: s.cfg.Pool.AllocateTimeout,
- DestroyTimeout: s.cfg.Pool.DestroyTimeout,
- Supervisor: s.cfg.Pool.Supervisor,
- }, s.cfg.Env, s.logCallback)
- if err != nil {
- return errors.E(op, err)
- }
-
s.server = server
return nil
@@ -141,6 +128,19 @@ func (s *Plugin) Serve() chan error {
errCh := make(chan error, 2)
var err error
+ s.pool, err = s.server.NewWorkerPool(context.Background(), pool.Config{
+ Debug: s.cfg.Pool.Debug,
+ NumWorkers: s.cfg.Pool.NumWorkers,
+ MaxJobs: s.cfg.Pool.MaxJobs,
+ AllocateTimeout: s.cfg.Pool.AllocateTimeout,
+ DestroyTimeout: s.cfg.Pool.DestroyTimeout,
+ Supervisor: s.cfg.Pool.Supervisor,
+ }, s.cfg.Env, s.logCallback)
+ if err != nil {
+ errCh <- errors.E(op, err)
+ return errCh
+ }
+
s.handler, err = NewHandler(
s.cfg.MaxRequestSize,
*s.cfg.Uploads,
@@ -303,12 +303,9 @@ func (s *Plugin) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Workers returns associated pool workers
func (s *Plugin) Workers() []worker.BaseProcess {
- workers := s.pool.Workers()
- baseWorkers := make([]worker.BaseProcess, 0, len(workers))
- for i := 0; i < len(workers); i++ {
- baseWorkers = append(baseWorkers, worker.FromSync(workers[i].(*worker.SyncWorkerImpl)))
- }
- return baseWorkers
+ s.Lock()
+ defer s.Unlock()
+ return s.pool.Workers()
}
// Name returns endure.Named interface implementation