Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sysulq committed May 11, 2018
1 parent f60822c commit 72ec64c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
34 changes: 34 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"


[[constraint]]
name = "github.com/prometheus/client_golang"
version = "0.8.0"

[[constraint]]
name = "github.com/sony/gobreaker"
branch = "master"

[[constraint]]
name = "github.com/stretchr/testify"
version = "1.2.1"
8 changes: 2 additions & 6 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ type command struct {
var (
// errPanic is returned when goroutine panics
errPanic = errors.New("command panics")
// errTooManyRequests is returned when the CB state is half open and the requests count is over the cb maxRequests
errTooManyRequests = errors.New("too many requests")
// errOpenState is returned when the CB state is open
errOpenState = errors.New("circuit breaker is open")
)

// errorWithFallback process error and fallback logic, with prometheus metrics
Expand Down Expand Up @@ -66,9 +62,9 @@ func errorToEvent(err error) string {
event = "context-deadline-exceeded"
case context.Canceled:
event = "context-cancled"
case errTooManyRequests:
case gobreaker.ErrTooManyRequests:
event = "too-many-requests"
case errOpenState:
case gobreaker.ErrOpenState:
event = "circuit-open"
case errPanic:
event = "panic"
Expand Down
2 changes: 2 additions & 0 deletions command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ import (

func TestErrorToEvent(t *testing.T) {
assert.Equal(t, "too-many-requests", errorToEvent(gobreaker.ErrTooManyRequests))
assert.Equal(t, "circuit-open", errorToEvent(gobreaker.ErrOpenState))
assert.Equal(t, "success", errorToEvent(nil))
}

0 comments on commit 72ec64c

Please sign in to comment.