diff options
author | Valery Piashchynski <[email protected]> | 2021-05-05 16:39:22 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-05-05 16:39:22 +0300 |
commit | 4fa94bb7f73a705293c2afd40fc1151a3aaa04e2 (patch) | |
tree | 6ffd858cade87600bbd4432f70db22f50c598db0 /pkg | |
parent | 9ee78f937d5be67058882dd3590f89da35bca239 (diff) |
- Initial broadcast commit
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pkg')
-rwxr-xr-x | pkg/payload/payload.go | 6 | ||||
-rwxr-xr-x | pkg/pool/static_pool.go | 6 | ||||
-rwxr-xr-x | pkg/pool/static_pool_test.go | 3 | ||||
-rw-r--r-- | pkg/worker_handler/handler.go | 2 |
4 files changed, 10 insertions, 7 deletions
diff --git a/pkg/payload/payload.go b/pkg/payload/payload.go index 1fe334eb..e1e45ac1 100755 --- a/pkg/payload/payload.go +++ b/pkg/payload/payload.go @@ -1,6 +1,8 @@ package payload -import "unsafe" +import ( + "github.com/spiral/roadrunner/v2/utils" +) // Payload carries binary header and body to stack and // back to the server. @@ -14,5 +16,5 @@ type Payload struct { // String returns payload body as string func (p *Payload) String() string { - return toString(p.Body) + return utils.AsString(p.Body) } diff --git a/pkg/pool/static_pool.go b/pkg/pool/static_pool.go index e769093c..54192262 100755 --- a/pkg/pool/static_pool.go +++ b/pkg/pool/static_pool.go @@ -4,7 +4,6 @@ import ( "context" "os/exec" "time" - "unsafe" "github.com/spiral/errors" "github.com/spiral/roadrunner/v2/pkg/events" @@ -12,6 +11,7 @@ import ( "github.com/spiral/roadrunner/v2/pkg/transport" "github.com/spiral/roadrunner/v2/pkg/worker" workerWatcher "github.com/spiral/roadrunner/v2/pkg/worker_watcher" + "github.com/spiral/roadrunner/v2/utils" ) // StopRequest can be sent by worker to indicate that restart is required. @@ -153,7 +153,7 @@ func (sp *StaticPool) Exec(p payload.Payload) (payload.Payload, error) { } // worker want's to be terminated - if len(rsp.Body) == 0 && toString(rsp.Context) == StopRequest { + if len(rsp.Body) == 0 && utils.AsString(rsp.Context) == StopRequest { sp.stopWorker(w) return sp.Exec(p) } @@ -183,7 +183,7 @@ func (sp *StaticPool) execWithTTL(ctx context.Context, p payload.Payload) (paylo } // worker want's to be terminated - if len(rsp.Body) == 0 && toString(rsp.Context) == StopRequest { + if len(rsp.Body) == 0 && utils.AsString(rsp.Context) == StopRequest { sp.stopWorker(w) return sp.execWithTTL(ctx, p) } diff --git a/pkg/pool/static_pool_test.go b/pkg/pool/static_pool_test.go index 69527815..bf7f10e0 100755 --- a/pkg/pool/static_pool_test.go +++ b/pkg/pool/static_pool_test.go @@ -16,6 +16,7 @@ import ( "github.com/spiral/roadrunner/v2/pkg/payload" "github.com/spiral/roadrunner/v2/pkg/transport/pipe" "github.com/spiral/roadrunner/v2/pkg/worker" + "github.com/spiral/roadrunner/v2/utils" "github.com/stretchr/testify/assert" ) @@ -653,7 +654,7 @@ func BenchmarkToStringUnsafe(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - res := toString(testPayload) + res := utils.AsString(testPayload) _ = res } } diff --git a/pkg/worker_handler/handler.go b/pkg/worker_handler/handler.go index be53fc12..d98cdef0 100644 --- a/pkg/worker_handler/handler.go +++ b/pkg/worker_handler/handler.go @@ -89,7 +89,7 @@ func (h *Handler) AddListener(l events.Listener) { // mdwr serve using PSR-7 requests passed to underlying application. Attempts to serve static files first if enabled. func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - const op = errors.Op("http_plugin_serve_http") + const op = errors.Op("serve_http") start := time.Now() // validating request size |