summaryrefslogtreecommitdiff
path: root/plugins/http/plugin.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-24 18:43:01 +0300
committerValery Piashchynski <[email protected]>2020-11-24 18:43:01 +0300
commit31559f018b2e9ee7eb53e635e8570259ff4d57e6 (patch)
tree1ce85ff673821dcf90c05511b184bf31fd454964 /plugins/http/plugin.go
parent7b68e0bdf0b7756ab1925ec0fbc71e08e7040c5a (diff)
Informer and Resetter tests
Diffstat (limited to 'plugins/http/plugin.go')
-rw-r--r--plugins/http/plugin.go27
1 files changed, 23 insertions, 4 deletions
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go
index 38539d52..b37a9700 100644
--- a/plugins/http/plugin.go
+++ b/plugins/http/plugin.go
@@ -95,7 +95,7 @@ func (s *Plugin) Init(cfg config.Configurer, log log.Logger, server factory.Serv
env := make(map[string]string)
env["RR_HTTP"] = "true"
- p, err := server.NewWorkerPool(context.Background(), roadrunner.PoolConfig{
+ s.pool, err = server.NewWorkerPool(context.Background(), roadrunner.PoolConfig{
Debug: s.cfg.Pool.Debug,
NumWorkers: s.cfg.Pool.NumWorkers,
MaxJobs: s.cfg.Pool.MaxJobs,
@@ -106,7 +106,8 @@ func (s *Plugin) Init(cfg config.Configurer, log log.Logger, server factory.Serv
if err != nil {
return errors.E(op, err)
}
- s.pool = p
+
+ s.server = server
s.AddListener(s.logCallback)
@@ -117,6 +118,8 @@ func (s *Plugin) logCallback(event interface{}) {
switch ev := event.(type) {
case ResponseEvent:
s.log.Info("response received", "elapsed", ev.Elapsed().String(), "remote address", ev.Request.RemoteAddr)
+ case ErrorEvent:
+ s.log.Error("error event received", "elapsed", ev.Elapsed().String(), "error", ev.Error)
default:
fmt.Println(event)
}
@@ -438,9 +441,15 @@ func (s *Plugin) Workers() []roadrunner.WorkerBase {
return s.pool.Workers()
}
+func (s *Plugin) Name() string {
+ return ServiceName
+}
+
func (s *Plugin) Reset() error {
s.Lock()
defer s.Unlock()
+ const op = errors.Op("http reset")
+ s.log.Info("Resetting http plugin")
s.pool.Destroy(context.Background())
// Set needed env vars
@@ -451,7 +460,7 @@ func (s *Plugin) Reset() error {
// re-read the config
err = s.configurer.UnmarshalKey(ServiceName, &s.cfg)
if err != nil {
- return err
+ return errors.E(op, err)
}
s.pool, err = s.server.NewWorkerPool(context.Background(), roadrunner.PoolConfig{
@@ -463,7 +472,17 @@ func (s *Plugin) Reset() error {
Supervisor: s.cfg.Pool.Supervisor,
}, env)
if err != nil {
- return err
+ return errors.E(op, err)
+ }
+
+ s.handler, err = NewHandler(
+ s.cfg.MaxRequestSize,
+ *s.cfg.Uploads,
+ s.cfg.cidrs,
+ s.pool,
+ )
+ if err != nil {
+ return errors.E(op, err)
}
// restore original listeners