From bd5748c6493113a80df5814a0da974d12e9327c6 Mon Sep 17 00:00:00 2001 From: Sagynbek Kenzhebaev Date: Tue, 16 Jan 2024 11:56:00 -0500 Subject: [PATCH 1/5] typo fix --- baseplate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baseplate.go b/baseplate.go index 0a86ff2ea..7b4991d58 100644 --- a/baseplate.go +++ b/baseplate.go @@ -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 From 3c88532a0421e6cf0cf4b9cfaa3ee3a87ba4030b Mon Sep 17 00:00:00 2001 From: Sagynbek Kenzhebaev Date: Tue, 16 Jan 2024 11:56:17 -0500 Subject: [PATCH 2/5] gobreaker version bump --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d3e705378..7e2fc5744 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 0c409949e..a0b7b6b9c 100644 --- a/go.sum +++ b/go.sum @@ -384,6 +384,8 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1 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= From da6fab70307710e8fb733efb153496389c9be6ad Mon Sep 17 00:00:00 2001 From: Sagynbek Kenzhebaev Date: Tue, 16 Jan 2024 11:56:59 -0500 Subject: [PATCH 3/5] Added IsSuccessful method to Config --- breakerbp/failure_ratio.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/breakerbp/failure_ratio.go b/breakerbp/failure_ratio.go index 6f3b24df0..2d581080a 100644 --- a/breakerbp/failure_ratio.go +++ b/breakerbp/failure_ratio.go @@ -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. @@ -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, } From e88ae88ee84d6dc2fec14a807acc1c6c4f91f35a Mon Sep 17 00:00:00 2001 From: Sagynbek Kenzhebaev Date: Tue, 16 Jan 2024 12:05:56 -0500 Subject: [PATCH 4/5] Run `go mod tidy` command --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index a0b7b6b9c..57cd716d6 100644 --- a/go.sum +++ b/go.sum @@ -382,8 +382,6 @@ 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= From b52f270f40d9e3f003d568b583fa2f412de431c7 Mon Sep 17 00:00:00 2001 From: Sagynbek Date: Tue, 16 Jan 2024 14:37:41 -0500 Subject: [PATCH 5/5] Update breakerbp/failure_ratio.go Co-authored-by: Yuxuan 'fishy' Wang --- breakerbp/failure_ratio.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/breakerbp/failure_ratio.go b/breakerbp/failure_ratio.go index 2d581080a..6ae50b895 100644 --- a/breakerbp/failure_ratio.go +++ b/breakerbp/failure_ratio.go @@ -81,7 +81,7 @@ type Config struct { // 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 + IsSuccessful func(err error) bool `yaml:"-"` } // NewFailureRatioBreaker creates a new FailureRatioBreaker with the provided configuration.