Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion baseplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func ParseConfigYAML(cfgPointer Configer) error {
return configbp.ParseStrictFile(configbp.BaseplateConfigPath, cfgPointer)
}

// NewArgs defines the args used in New functino.
// NewArgs defines the args used in New function.
type NewArgs struct {
// Required. New will panic if this is nil.
Config Configer
Expand Down
7 changes: 7 additions & 0 deletions breakerbp/failure_ratio.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ type Config struct {

// Timeout is the duration of the 'Open' state. After an 'Open' timeout duration has passed, the breaker enters 'half-open' state.
Timeout time.Duration `yaml:"timeout"`

// IsSuccessful is called with the error returned from a request.
// If IsSuccessful returns true, the error is counted as a success.
// Otherwise the error is counted as a failure.
// If IsSuccessful is nil, default IsSuccessful is used, which returns false for all non-nil errors.
IsSuccessful func(err error) bool
}

// NewFailureRatioBreaker creates a new FailureRatioBreaker with the provided configuration.
Expand All @@ -92,6 +98,7 @@ func NewFailureRatioBreaker(config Config) FailureRatioBreaker {
Interval: config.Interval,
Timeout: config.Timeout,
MaxRequests: config.MaxRequestsHalfOpen,
IsSuccessful: config.IsSuccessful,
ReadyToTrip: failureBreaker.shouldTrip,
OnStateChange: failureBreaker.stateChanged,
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0
github.com/prometheus/client_golang v1.13.0
github.com/prometheus/client_model v0.2.0
github.com/sony/gobreaker v0.4.1
github.com/sony/gobreaker v0.5.0
go.uber.org/automaxprocs v1.5.1
go.uber.org/zap v1.24.0
golang.org/x/sys v0.15.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/sony/gobreaker v0.4.1 h1:oMnRNZXX5j85zso6xCPRNPtmAycat+WcoKbklScLDgQ=
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
github.com/sony/gobreaker v0.5.0 h1:dRCvqm0P490vZPmy7ppEk2qCnCieBooFJ+YoXGYB+yg=
github.com/sony/gobreaker v0.5.0/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
Expand Down