diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-01-13 07:07:16 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-13 07:07:16 +0000 |
commit | f18e7f6920590ee6f2e59be508518b70a4611638 (patch) | |
tree | 2f80c427e740c2c6f7f2a47be2b869b6d9847e58 /cmd | |
parent | 5dc83ef5eee77f4d1ef557e5f8b566e75892680d (diff) | |
parent | bbfcd4fb6eb138c616dab01ea610fbf6ed15985b (diff) |
Merge #472
472: feat(http): Distinct app and internal error codes in the handleError function r=48d90782 a=48d90782
This PR introduces distinct error codes for the app and internal RR errors.
Errors:
```go
roadrunner.ErrNoAssociatedPool
roadrunner.ErrAllocateWorker
roadrunner.ErrWorkerNotReady
roadrunner.ErrEmptyPayload
roadrunner.ErrPoolStopped
roadrunner.ErrWorkerAllocateTimeout
roadrunner.ErrAllWorkersAreDead
```
now associated with the internal error codes. All other errors are application errors.
Some types of errors are impossible to distinguish in the RR1, for example `json.Unmarshall` internal error or similar.
The `.rr.yaml` now contain two more options for the errors.
```yaml
http:
internalErrorCode: 502,
appErrorCode: 502
```
Default behavior unchanged (500 error code as before), but now might be overridden.
closes #471
Co-authored-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/rr/cmd/root.go | 9 | ||||
-rw-r--r-- | cmd/rr/cmd/serve.go | 3 | ||||
-rw-r--r-- | cmd/rr/http/debug.go | 9 | ||||
-rw-r--r-- | cmd/rr/http/metrics.go | 5 | ||||
-rw-r--r-- | cmd/rr/http/workers.go | 11 | ||||
-rw-r--r-- | cmd/util/config.go | 5 | ||||
-rw-r--r-- | cmd/util/cprint.go | 3 | ||||
-rw-r--r-- | cmd/util/debug.go | 3 | ||||
-rw-r--r-- | cmd/util/rpc.go | 3 | ||||
-rw-r--r-- | cmd/util/table.go | 7 |
10 files changed, 34 insertions, 24 deletions
diff --git a/cmd/rr/cmd/root.go b/cmd/rr/cmd/root.go index e67a4e62..13d74d25 100644 --- a/cmd/rr/cmd/root.go +++ b/cmd/rr/cmd/root.go @@ -21,15 +21,16 @@ package cmd import ( + "log" + "net/http" + "net/http/pprof" + "os" + "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spiral/roadrunner/cmd/util" "github.com/spiral/roadrunner/service" "github.com/spiral/roadrunner/service/limit" - "log" - "net/http" - "net/http/pprof" - "os" ) // Services bus for all the commands. diff --git a/cmd/rr/cmd/serve.go b/cmd/rr/cmd/serve.go index cafbdd4f..70682780 100644 --- a/cmd/rr/cmd/serve.go +++ b/cmd/rr/cmd/serve.go @@ -21,11 +21,12 @@ package cmd import ( - "github.com/spf13/cobra" "os" "os/signal" "sync" "syscall" + + "github.com/spf13/cobra" ) func init() { diff --git a/cmd/rr/http/debug.go b/cmd/rr/http/debug.go index ae383e8d..02023e36 100644 --- a/cmd/rr/http/debug.go +++ b/cmd/rr/http/debug.go @@ -2,16 +2,17 @@ package http import ( "fmt" + "net" + "net/http" + "strings" + "time" + "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spiral/roadrunner" rr "github.com/spiral/roadrunner/cmd/rr/cmd" "github.com/spiral/roadrunner/cmd/util" rrhttp "github.com/spiral/roadrunner/service/http" - "net" - "net/http" - "strings" - "time" ) func init() { diff --git a/cmd/rr/http/metrics.go b/cmd/rr/http/metrics.go index 21bbbaf1..6aad560e 100644 --- a/cmd/rr/http/metrics.go +++ b/cmd/rr/http/metrics.go @@ -1,14 +1,15 @@ package http import ( + "strconv" + "time" + "github.com/prometheus/client_golang/prometheus" "github.com/spf13/cobra" rr "github.com/spiral/roadrunner/cmd/rr/cmd" rrhttp "github.com/spiral/roadrunner/service/http" "github.com/spiral/roadrunner/service/metrics" "github.com/spiral/roadrunner/util" - "strconv" - "time" ) func init() { diff --git a/cmd/rr/http/workers.go b/cmd/rr/http/workers.go index 4444b87f..be6d4038 100644 --- a/cmd/rr/http/workers.go +++ b/cmd/rr/http/workers.go @@ -21,16 +21,17 @@ package http import ( - tm "github.com/buger/goterm" - "github.com/spf13/cobra" - rr "github.com/spiral/roadrunner/cmd/rr/cmd" - "github.com/spiral/roadrunner/cmd/util" - "github.com/spiral/roadrunner/service/http" "net/rpc" "os" "os/signal" "syscall" "time" + + tm "github.com/buger/goterm" + "github.com/spf13/cobra" + rr "github.com/spiral/roadrunner/cmd/rr/cmd" + "github.com/spiral/roadrunner/cmd/util" + "github.com/spiral/roadrunner/service/http" ) var ( diff --git a/cmd/util/config.go b/cmd/util/config.go index 08e01a89..674260a8 100644 --- a/cmd/util/config.go +++ b/cmd/util/config.go @@ -3,11 +3,12 @@ package util import ( "bytes" "fmt" - "github.com/spf13/viper" - "github.com/spiral/roadrunner/service" "os" "path/filepath" "strings" + + "github.com/spf13/viper" + "github.com/spiral/roadrunner/service" ) // ConfigWrapper provides interface bridge between v configs and service.Config. diff --git a/cmd/util/cprint.go b/cmd/util/cprint.go index 3a986fd6..37cb0bc5 100644 --- a/cmd/util/cprint.go +++ b/cmd/util/cprint.go @@ -2,10 +2,11 @@ package util import ( "fmt" - "github.com/mgutz/ansi" "os" "regexp" "strings" + + "github.com/mgutz/ansi" ) var ( diff --git a/cmd/util/debug.go b/cmd/util/debug.go index 9b94510d..c5cf68bb 100644 --- a/cmd/util/debug.go +++ b/cmd/util/debug.go @@ -1,9 +1,10 @@ package util import ( + "strings" + "github.com/sirupsen/logrus" "github.com/spiral/roadrunner" - "strings" ) // LogEvent outputs rr event into given logger and return false if event was not handled. diff --git a/cmd/util/rpc.go b/cmd/util/rpc.go index 8ff6720a..cb88943e 100644 --- a/cmd/util/rpc.go +++ b/cmd/util/rpc.go @@ -2,9 +2,10 @@ package util import ( "errors" + "net/rpc" + "github.com/spiral/roadrunner/service" rrpc "github.com/spiral/roadrunner/service/rpc" - "net/rpc" ) // RPCClient returns RPC client associated with given rr service container. diff --git a/cmd/util/table.go b/cmd/util/table.go index c0e20837..4f76be2c 100644 --- a/cmd/util/table.go +++ b/cmd/util/table.go @@ -1,12 +1,13 @@ package util import ( - "github.com/dustin/go-humanize" - "github.com/olekukonko/tablewriter" - rrutil "github.com/spiral/roadrunner/util" "os" "strconv" "time" + + "github.com/dustin/go-humanize" + "github.com/olekukonko/tablewriter" + rrutil "github.com/spiral/roadrunner/util" ) // WorkerTable renders table with information about rr server workers. |