diff options
author | Valery Piashchynski <[email protected]> | 2020-12-17 02:34:44 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-12-17 02:34:44 +0300 |
commit | 9d5fe4f6a98b30fd73be8259f84fa595ac994a71 (patch) | |
tree | e49c46b03d8facc73e96f1b6247d83367cc65398 /plugins/http/handler.go | |
parent | 1033c25b6bfc752d6059e446510f651e22cbf49b (diff) |
huge refactor
Diffstat (limited to 'plugins/http/handler.go')
-rw-r--r-- | plugins/http/handler.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/plugins/http/handler.go b/plugins/http/handler.go index 74b038ff..4cc08c41 100644 --- a/plugins/http/handler.go +++ b/plugins/http/handler.go @@ -10,9 +10,9 @@ import ( "github.com/hashicorp/go-multierror" "github.com/spiral/errors" - "github.com/spiral/roadrunner/v2" "github.com/spiral/roadrunner/v2/interfaces/log" - "github.com/spiral/roadrunner/v2/util" + "github.com/spiral/roadrunner/v2/interfaces/pool" + "github.com/spiral/roadrunner/v2/interfaces/worker" ) const ( @@ -23,8 +23,10 @@ const ( EventError ) +const MB = 1024 * 1024 + type Handle interface { - AddListener(l util.EventListener) + AddListener(l worker.EventListener) ServeHTTP(w http.ResponseWriter, r *http.Request) } @@ -71,17 +73,17 @@ type handler struct { uploads UploadsConfig trusted Cidrs log log.Logger - pool roadrunner.Pool + pool pool.Pool mul sync.Mutex - lsn util.EventListener + lsn worker.EventListener } -func NewHandler(maxReqSize uint64, uploads UploadsConfig, trusted Cidrs, pool roadrunner.Pool) (Handle, error) { +func NewHandler(maxReqSize uint64, uploads UploadsConfig, trusted Cidrs, pool pool.Pool) (Handle, error) { if pool == nil { return nil, errors.E(errors.Str("pool should be initialized")) } return &handler{ - maxRequestSize: maxReqSize * roadrunner.MB, + maxRequestSize: maxReqSize * MB, uploads: uploads, pool: pool, trusted: trusted, @@ -89,7 +91,7 @@ func NewHandler(maxReqSize uint64, uploads UploadsConfig, trusted Cidrs, pool ro } // Listen attaches handler event controller. -func (h *handler) AddListener(l util.EventListener) { +func (h *handler) AddListener(l worker.EventListener) { h.mul.Lock() defer h.mul.Unlock() |