diff options
32 files changed, 97 insertions, 102 deletions
diff --git a/cmd/rr/cmd/root.go b/cmd/rr/cmd/root.go index bea42747..b1f3ea9a 100644 --- a/cmd/rr/cmd/root.go +++ b/cmd/rr/cmd/root.go @@ -24,8 +24,8 @@ import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/spiral/roadrunner/service" "github.com/spiral/roadrunner/cmd/rr/utils" + "github.com/spiral/roadrunner/service" "os" ) diff --git a/cmd/rr/debug/listener.go b/cmd/rr/debug/listener.go index 1b6fcf83..f137b06f 100644 --- a/cmd/rr/debug/listener.go +++ b/cmd/rr/debug/listener.go @@ -2,9 +2,9 @@ package debug import ( "github.com/sirupsen/logrus" - "github.com/spiral/roadrunner/service/http" - "github.com/spiral/roadrunner/cmd/rr/utils" "github.com/spiral/roadrunner" + "github.com/spiral/roadrunner/cmd/rr/utils" + "github.com/spiral/roadrunner/service/http" ) // Listener provide debug callback for system events. With colors! diff --git a/cmd/rr/http/reset.go b/cmd/rr/http/reset.go index 9e3dec3d..431b7e88 100644 --- a/cmd/rr/http/reset.go +++ b/cmd/rr/http/reset.go @@ -24,9 +24,9 @@ import ( "errors" "github.com/spf13/cobra" rr "github.com/spiral/roadrunner/cmd/rr/cmd" - "github.com/spiral/roadrunner/service/rpc" - "github.com/spiral/roadrunner/service" "github.com/spiral/roadrunner/cmd/rr/utils" + "github.com/spiral/roadrunner/service" + "github.com/spiral/roadrunner/service/rpc" ) func init() { diff --git a/cmd/rr/http/workers.go b/cmd/rr/http/workers.go index a70762af..fd3927e7 100644 --- a/cmd/rr/http/workers.go +++ b/cmd/rr/http/workers.go @@ -28,16 +28,16 @@ import ( "github.com/shirou/gopsutil/process" "github.com/spf13/cobra" rr "github.com/spiral/roadrunner/cmd/rr/cmd" + "github.com/spiral/roadrunner/cmd/rr/utils" + "github.com/spiral/roadrunner/service" "github.com/spiral/roadrunner/service/http" rrpc "github.com/spiral/roadrunner/service/rpc" - "github.com/spiral/roadrunner/service" - "github.com/spiral/roadrunner/cmd/rr/utils" "net/rpc" "os" - "strconv" - "time" "os/signal" + "strconv" "syscall" + "time" ) var ( diff --git a/cmd/rr/main.go b/cmd/rr/main.go index ee6b915b..40f191c6 100644 --- a/cmd/rr/main.go +++ b/cmd/rr/main.go @@ -31,8 +31,8 @@ import ( "github.com/spiral/roadrunner/service/static" // cli plugins - _ "github.com/spiral/roadrunner/cmd/rr/http" "github.com/spiral/roadrunner/cmd/rr/debug" + _ "github.com/spiral/roadrunner/cmd/rr/http" "github.com/spf13/cobra" ) @@ -51,7 +51,7 @@ func main() { rr.Container.Register(static.ID, &static.Service{}) // debug mode - rr.CLI.PersistentFlags().BoolVarP(&debugMode, "debug", "d", false, "debug mode", ) + rr.CLI.PersistentFlags().BoolVarP(&debugMode, "debug", "d", false, "debug mode") cobra.OnInitialize(func() { if debugMode { service, _ := rr.Container.Get(http.ID) diff --git a/cmd/rr/utils/cprint.go b/cmd/rr/utils/cprint.go index e0fb6931..020975ec 100644 --- a/cmd/rr/utils/cprint.go +++ b/cmd/rr/utils/cprint.go @@ -2,9 +2,9 @@ package utils import ( "fmt" + "github.com/mgutz/ansi" "regexp" "strings" - "github.com/mgutz/ansi" ) var reg *regexp.Regexp @@ -25,4 +25,4 @@ func Sprintf(format string, args ...interface{}) string { }) return fmt.Sprintf(format, args...) -}
\ No newline at end of file +} @@ -2,8 +2,8 @@ package roadrunner import ( "fmt" - "sync" "github.com/pkg/errors" + "sync" ) const ( diff --git a/server_config.go b/server_config.go index 8af0e0f8..c6567fc3 100644 --- a/server_config.go +++ b/server_config.go @@ -3,9 +3,9 @@ package roadrunner import ( "errors" "net" + "os/exec" "strings" "time" - "os/exec" ) // Server config combines factory, pool and cmd configurations. diff --git a/server_test.go b/server_test.go index 13cacc2c..846b1040 100644 --- a/server_test.go +++ b/server_test.go @@ -2,10 +2,10 @@ package roadrunner import ( "github.com/stretchr/testify/assert" + "os/exec" "runtime" "testing" "time" - "os/exec" ) func TestServer_PipesEcho(t *testing.T) { diff --git a/service/container.go b/service/container.go index 9eaba781..98b24a11 100644 --- a/service/container.go +++ b/service/container.go @@ -129,7 +129,7 @@ func (c *container) Serve() error { for _, e := range c.services { if e.hasStatus(StatusConfigured) { - numServing ++ + numServing++ } else { continue } diff --git a/service/container_test.go b/service/container_test.go index 3c2f8761..3092be78 100644 --- a/service/container_test.go +++ b/service/container_test.go @@ -1,14 +1,14 @@ package service import ( - "testing" - "github.com/sirupsen/logrus/hooks/test" - "github.com/stretchr/testify/assert" - "github.com/sirupsen/logrus" "encoding/json" "errors" - "time" + "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus/hooks/test" + "github.com/stretchr/testify/assert" "sync" + "testing" + "time" ) type testService struct { diff --git a/service/http/config.go b/service/http/config.go index 2bc5f845..de791f45 100644 --- a/service/http/config.go +++ b/service/http/config.go @@ -1,8 +1,8 @@ package http import ( - "github.com/spiral/roadrunner" "errors" + "github.com/spiral/roadrunner" "strings" ) diff --git a/service/http/config_test.go b/service/http/config_test.go index b806b79b..44c58f35 100644 --- a/service/http/config_test.go +++ b/service/http/config_test.go @@ -1,10 +1,10 @@ package http import ( - "testing" - "os" - "github.com/stretchr/testify/assert" "github.com/spiral/roadrunner" + "github.com/stretchr/testify/assert" + "os" + "testing" "time" ) diff --git a/service/http/handler.go b/service/http/handler.go index a4cb6406..2c7c1fad 100644 --- a/service/http/handler.go +++ b/service/http/handler.go @@ -1,10 +1,10 @@ package http import ( + "github.com/pkg/errors" + "github.com/spiral/roadrunner" "net/http" "strconv" - "github.com/spiral/roadrunner" - "github.com/pkg/errors" "sync" ) diff --git a/service/http/handler_test.go b/service/http/handler_test.go index d599b1d8..4a11c562 100644 --- a/service/http/handler_test.go +++ b/service/http/handler_test.go @@ -1,19 +1,19 @@ package http import ( - "net/http" - "io/ioutil" + "bytes" + "context" "github.com/spiral/roadrunner" - "testing" - "os" "github.com/stretchr/testify/assert" + "io/ioutil" + "mime/multipart" + "net/http" "net/url" + "os" + "runtime" "strings" - "context" - "bytes" - "mime/multipart" + "testing" "time" - "runtime" ) // get request and return body @@ -86,7 +86,7 @@ func TestServer_Headers(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8078", Handler: st,} + hs := &http.Server{Addr: ":8078", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() @@ -133,7 +133,7 @@ func TestServer_Cookies(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8079", Handler: st,} + hs := &http.Server{Addr: ":8079", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() @@ -184,7 +184,7 @@ func TestServer_JsonPayload_POST(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8090", Handler: st,} + hs := &http.Server{Addr: ":8090", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() @@ -326,7 +326,7 @@ func TestServer_FormData_POST(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8083", Handler: st,} + hs := &http.Server{Addr: ":8083", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() diff --git a/service/http/request.go b/service/http/request.go index d88c260e..2e8ae090 100644 --- a/service/http/request.go +++ b/service/http/request.go @@ -6,8 +6,8 @@ import ( "github.com/spiral/roadrunner" "io/ioutil" "net/http" - "strings" "net/url" + "strings" ) const ( diff --git a/service/http/response.go b/service/http/response.go index 69bcf3e1..d43f514d 100644 --- a/service/http/response.go +++ b/service/http/response.go @@ -3,8 +3,8 @@ package http import ( "encoding/json" "github.com/spiral/roadrunner" - "net/http" "io" + "net/http" ) // Response handles PSR7 response logic. diff --git a/service/http/response_test.go b/service/http/response_test.go index e45f5349..f885be7f 100644 --- a/service/http/response_test.go +++ b/service/http/response_test.go @@ -1,12 +1,12 @@ package http import ( - "net/http" "bytes" - "testing" + "errors" "github.com/spiral/roadrunner" "github.com/stretchr/testify/assert" - "errors" + "net/http" + "testing" ) type testWriter struct { diff --git a/service/http/rpc_test.go b/service/http/rpc_test.go index f1c5786c..fc47a70f 100644 --- a/service/http/rpc_test.go +++ b/service/http/rpc_test.go @@ -1,14 +1,14 @@ package http import ( - "testing" - "github.com/sirupsen/logrus/hooks/test" "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus/hooks/test" "github.com/spiral/roadrunner/service" - "github.com/stretchr/testify/assert" - "time" "github.com/spiral/roadrunner/service/rpc" + "github.com/stretchr/testify/assert" "strconv" + "testing" + "time" ) func Test_RPC(t *testing.T) { @@ -112,4 +112,4 @@ func Test_Workers(t *testing.T) { assert.Len(t, r.Workers, 1) assert.Equal(t, *ss.rr.Workers()[0].Pid, r.Workers[0].Pid) -}
\ No newline at end of file +} diff --git a/service/http/service.go b/service/http/service.go index 8485cba6..70980859 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -1,11 +1,11 @@ package http import ( - "net/http" - "github.com/spiral/roadrunner/service" "context" "github.com/spiral/roadrunner" + "github.com/spiral/roadrunner/service" "github.com/spiral/roadrunner/service/rpc" + "net/http" "sync" ) diff --git a/service/http/service_test.go b/service/http/service_test.go index ebcd0f5a..55fa660b 100644 --- a/service/http/service_test.go +++ b/service/http/service_test.go @@ -1,18 +1,18 @@ package http import ( - "testing" - "github.com/spiral/roadrunner/service" - "github.com/sirupsen/logrus/hooks/test" - "github.com/sirupsen/logrus" "encoding/json" + "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus/hooks/test" + "github.com/spiral/roadrunner" + "github.com/spiral/roadrunner/service" + "github.com/spiral/roadrunner/service/rpc" "github.com/stretchr/testify/assert" + "io/ioutil" + "net/http" "os" + "testing" "time" - "net/http" - "io/ioutil" - "github.com/spiral/roadrunner" - "github.com/spiral/roadrunner/service/rpc" ) type testCfg struct { diff --git a/service/http/uploads.go b/service/http/uploads.go index f8334c30..4607dea4 100644 --- a/service/http/uploads.go +++ b/service/http/uploads.go @@ -2,11 +2,11 @@ package http import ( "encoding/json" + "io" + "io/ioutil" + "mime/multipart" "os" "sync" - "mime/multipart" - "io/ioutil" - "io" ) const ( diff --git a/service/http/uploads_config.go b/service/http/uploads_config.go index 715de69a..148ebba3 100644 --- a/service/http/uploads_config.go +++ b/service/http/uploads_config.go @@ -1,9 +1,9 @@ package http import ( - "strings" - "path" "os" + "path" + "strings" ) // UploadsConfig describes file location and controls access to them. diff --git a/service/http/uploads_config_test.go b/service/http/uploads_config_test.go index 7704a486..2b6ceebc 100644 --- a/service/http/uploads_config_test.go +++ b/service/http/uploads_config_test.go @@ -1,9 +1,9 @@ package http import ( - "testing" "github.com/stretchr/testify/assert" "os" + "testing" ) func TestFsConfig_Forbids(t *testing.T) { diff --git a/service/http/uploads_test.go b/service/http/uploads_test.go index af351067..b2662bf7 100644 --- a/service/http/uploads_test.go +++ b/service/http/uploads_test.go @@ -1,20 +1,20 @@ package http import ( - "github.com/spiral/roadrunner" - "github.com/stretchr/testify/assert" - "net/http" - "time" "bytes" - "mime/multipart" - "io/ioutil" - "testing" - "os" "context" - "io" - "encoding/json" "crypto/md5" "encoding/hex" + "encoding/json" + "github.com/spiral/roadrunner" + "github.com/stretchr/testify/assert" + "io" + "io/ioutil" + "mime/multipart" + "net/http" + "os" + "testing" + "time" ) func TestServer_Upload_File(t *testing.T) { @@ -40,7 +40,7 @@ func TestServer_Upload_File(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8021", Handler: st,} + hs := &http.Server{Addr: ":8021", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() @@ -101,7 +101,7 @@ func TestServer_Upload_NestedFile(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8021", Handler: st,} + hs := &http.Server{Addr: ":8021", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() @@ -139,7 +139,6 @@ func TestServer_Upload_NestedFile(t *testing.T) { assert.Equal(t, `{"upload":{"x":{"y":{"z":[`+fs+`]}}}}`, string(b)) } - func TestServer_Upload_File_NoTmpDir(t *testing.T) { st := &Handler{ cfg: &Config{ @@ -163,7 +162,7 @@ func TestServer_Upload_File_NoTmpDir(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8021", Handler: st,} + hs := &http.Server{Addr: ":8021", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() @@ -201,7 +200,6 @@ func TestServer_Upload_File_NoTmpDir(t *testing.T) { assert.Equal(t, `{"upload":`+fs+`}`, string(b)) } - func TestServer_Upload_File_Forbids(t *testing.T) { st := &Handler{ cfg: &Config{ @@ -225,7 +223,7 @@ func TestServer_Upload_File_Forbids(t *testing.T) { assert.NoError(t, st.rr.Start()) defer st.rr.Stop() - hs := &http.Server{Addr: ":8021", Handler: st,} + hs := &http.Server{Addr: ":8021", Handler: st} defer hs.Shutdown(context.Background()) go func() { hs.ListenAndServe() }() diff --git a/service/static/config.go b/service/static/config.go index 2a1f6c13..d55fcd66 100644 --- a/service/static/config.go +++ b/service/static/config.go @@ -1,10 +1,10 @@ package static import ( - "strings" - "path" - "os" "github.com/pkg/errors" + "os" + "path" + "strings" ) // Config describes file location and controls access to them. diff --git a/service/static/config_test.go b/service/static/config_test.go index ce31348a..d2099cdf 100644 --- a/service/static/config_test.go +++ b/service/static/config_test.go @@ -1,8 +1,8 @@ package static import ( - "testing" "github.com/stretchr/testify/assert" + "testing" ) func TestConfig_Forbids(t *testing.T) { diff --git a/service/static/service.go b/service/static/service.go index 43891aa8..545c96bf 100644 --- a/service/static/service.go +++ b/service/static/service.go @@ -1,11 +1,11 @@ package static import ( + "github.com/spiral/roadrunner/service" + rrttp "github.com/spiral/roadrunner/service/http" "net/http" "path" "strings" - rrttp "github.com/spiral/roadrunner/service/http" - "github.com/spiral/roadrunner/service" ) // ID contains default service name. diff --git a/service/static/service_test.go b/service/static/service_test.go index f0cb1bea..842e5e0b 100644 --- a/service/static/service_test.go +++ b/service/static/service_test.go @@ -1,19 +1,19 @@ package static import ( - "testing" - "github.com/sirupsen/logrus/hooks/test" + "bytes" + "encoding/json" "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus/hooks/test" "github.com/spiral/roadrunner/service" - "github.com/stretchr/testify/assert" - "time" rrhttp "github.com/spiral/roadrunner/service/http" - "encoding/json" + "github.com/stretchr/testify/assert" + "io" "io/ioutil" "net/http" "os" - "bytes" - "io" + "testing" + "time" ) type testCfg struct { @@ -84,7 +84,6 @@ func Test_Files(t *testing.T) { assert.Equal(t, "sample", b) } - func Test_Files_Disable(t *testing.T) { logger, _ := test.NewNullLogger() logger.SetLevel(logrus.DebugLevel) @@ -256,7 +255,6 @@ func Test_Files_NotFound(t *testing.T) { assert.Equal(t, "WORLD", b) } - func Test_Files_Dir(t *testing.T) { logger, _ := test.NewNullLogger() logger.SetLevel(logrus.DebugLevel) diff --git a/static_pool.go b/static_pool.go index 9449ea0c..975ddbe4 100644 --- a/static_pool.go +++ b/static_pool.go @@ -5,8 +5,8 @@ import ( "github.com/pkg/errors" "os/exec" "sync" - "time" "sync/atomic" + "time" ) const ( diff --git a/static_pool_test.go b/static_pool_test.go index 231bc71b..548fb126 100644 --- a/static_pool_test.go +++ b/static_pool_test.go @@ -2,13 +2,13 @@ package roadrunner import ( "github.com/stretchr/testify/assert" + "log" "os/exec" "runtime" "strconv" + "sync" "testing" "time" - "sync" - "log" ) var cfg = Config{ @@ -266,7 +266,6 @@ func Test_StaticPool_Replace_Worker(t *testing.T) { } } - // identical to replace but controlled on worker side func Test_StaticPool_Stop_Worker(t *testing.T) { p, err := NewPool( diff --git a/worker_test.go b/worker_test.go index 2e3bc111..053a97b1 100644 --- a/worker_test.go +++ b/worker_test.go @@ -190,4 +190,4 @@ func Test_NumExecs(t *testing.T) { w.Exec(&Payload{Body: []byte("hello")}) assert.Equal(t, int64(3), w.State().NumExecs()) -}
\ No newline at end of file +} |