fix(deps): update sony/gobreaker to v2

The v2 module path is github.com/sony/gobreaker/v2 and the breaker is
generic. The code instantiates it with any, which matches the v1
Execute signature.
This commit is contained in:
2026-10-04 10:16:43 +01:00
parent 02780d942c
commit 4d87dee2c6
11 changed files with 19 additions and 19 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ import (
libpack_cache "github.com/lukaszraczylo/graphql-monitoring-proxy/cache" libpack_cache "github.com/lukaszraczylo/graphql-monitoring-proxy/cache"
libpack_config "github.com/lukaszraczylo/graphql-monitoring-proxy/config" libpack_config "github.com/lukaszraczylo/graphql-monitoring-proxy/config"
libpack_logger "github.com/lukaszraczylo/graphql-monitoring-proxy/logging" libpack_logger "github.com/lukaszraczylo/graphql-monitoring-proxy/logging"
"github.com/sony/gobreaker" "github.com/sony/gobreaker/v2"
) )
var bannedUsersIDs sync.Map // key: userID string, value: reason string var bannedUsersIDs sync.Map // key: userID string, value: reason string
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"github.com/gofiber/fiber/v3" "github.com/gofiber/fiber/v3"
libpack_cache "github.com/lukaszraczylo/graphql-monitoring-proxy/cache" libpack_cache "github.com/lukaszraczylo/graphql-monitoring-proxy/cache"
libpack_monitoring "github.com/lukaszraczylo/graphql-monitoring-proxy/monitoring" libpack_monitoring "github.com/lukaszraczylo/graphql-monitoring-proxy/monitoring"
"github.com/sony/gobreaker" "github.com/sony/gobreaker/v2"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
) )
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"errors" "errors"
"time" "time"
"github.com/sony/gobreaker" "github.com/sony/gobreaker/v2"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
+5 -5
View File
@@ -15,7 +15,7 @@ import (
libpack_cache_memory "github.com/lukaszraczylo/graphql-monitoring-proxy/cache/memory" libpack_cache_memory "github.com/lukaszraczylo/graphql-monitoring-proxy/cache/memory"
libpack_logger "github.com/lukaszraczylo/graphql-monitoring-proxy/logging" libpack_logger "github.com/lukaszraczylo/graphql-monitoring-proxy/logging"
libpack_monitoring "github.com/lukaszraczylo/graphql-monitoring-proxy/monitoring" libpack_monitoring "github.com/lukaszraczylo/graphql-monitoring-proxy/monitoring"
"github.com/sony/gobreaker" "github.com/sony/gobreaker/v2"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
@@ -497,7 +497,7 @@ func (suite *CircuitBreakerTestSuite) TestCircuitBreakerFailureRatioWindow() {
func (suite *CircuitBreakerTestSuite) TestCircuitBackoffResetsOnSuccessfulRecovery() { func (suite *CircuitBreakerTestSuite) TestCircuitBackoffResetsOnSuccessfulRecovery() {
cbMutex.Lock() cbMutex.Lock()
cbBackoff.reset() cbBackoff.reset()
cb = gobreaker.NewCircuitBreaker(gobreaker.Settings{ cb = gobreaker.NewCircuitBreaker[any](gobreaker.Settings{
Name: "recovery-test", Name: "recovery-test",
MaxRequests: 1, MaxRequests: 1,
Timeout: 5 * time.Millisecond, Timeout: 5 * time.Millisecond,
@@ -682,7 +682,7 @@ func TestCircuitBackoffGateBlocks(t *testing.T) {
testCfg.CircuitBreaker.BackoffMultiplier = tt.multiplier testCfg.CircuitBreaker.BackoffMultiplier = tt.multiplier
testCfg.CircuitBreaker.MaxBackoffTimeout = int(tt.maxBackoff / time.Second) testCfg.CircuitBreaker.MaxBackoffTimeout = int(tt.maxBackoff / time.Second)
breaker := gobreaker.NewCircuitBreaker(gobreaker.Settings{Name: "gate-test"}) breaker := gobreaker.NewCircuitBreaker[any](gobreaker.Settings{Name: "gate-test"})
now := tripTime.Add(tt.elapsed) now := tripTime.Add(tt.elapsed)
got := circuitBackoffGateBlocks(testCfg, breaker, now) got := circuitBackoffGateBlocks(testCfg, breaker, now)
@@ -725,10 +725,10 @@ func TestCircuitBackoffLongerClosedDoorWithHigherMultiplier(t *testing.T) {
cfgProgressive.CircuitBreaker.BackoffMultiplier = 2.0 cfgProgressive.CircuitBreaker.BackoffMultiplier = 2.0
seed() seed()
blockedAtDefault := circuitBackoffGateBlocks(cfgDefault, gobreaker.NewCircuitBreaker(gobreaker.Settings{Name: "default"}), now) blockedAtDefault := circuitBackoffGateBlocks(cfgDefault, gobreaker.NewCircuitBreaker[any](gobreaker.Settings{Name: "default"}), now)
seed() seed()
blockedAtProgressive := circuitBackoffGateBlocks(cfgProgressive, gobreaker.NewCircuitBreaker(gobreaker.Settings{Name: "progressive"}), now) blockedAtProgressive := circuitBackoffGateBlocks(cfgProgressive, gobreaker.NewCircuitBreaker[any](gobreaker.Settings{Name: "progressive"}), now)
assert.False(t, blockedAtDefault, "multiplier=1.0 (default): base has already elapsed, gate must match today's behaviour and not block") assert.False(t, blockedAtDefault, "multiplier=1.0 (default): base has already elapsed, gate must match today's behaviour and not block")
assert.True(t, blockedAtProgressive, "multiplier=2.0: effective backoff has not yet elapsed at the same instant, gate must still block -- strictly longer closed-door time than the default") assert.True(t, blockedAtProgressive, "multiplier=2.0: effective backoff has not yet elapsed at the same instant, gate must still block -- strictly longer closed-door time than the default")
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/sony/gobreaker" "github.com/sony/gobreaker/v2"
) )
// Error codes for structured error responses // Error codes for structured error responses
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"net/http" "net/http"
"testing" "testing"
"github.com/sony/gobreaker" "github.com/sony/gobreaker/v2"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
+1 -1
View File
@@ -24,7 +24,7 @@ require (
github.com/lukaszraczylo/go-simple-graphql v1.2.89 github.com/lukaszraczylo/go-simple-graphql v1.2.89
github.com/lukaszraczylo/oss-telemetry v0.2.5 github.com/lukaszraczylo/oss-telemetry v0.2.5
github.com/redis/go-redis/v9 v9.22.0 github.com/redis/go-redis/v9 v9.22.0
github.com/sony/gobreaker v1.0.0 github.com/sony/gobreaker/v2 v2.4.0
github.com/stretchr/testify v1.12.1 github.com/stretchr/testify v1.12.1
github.com/valyala/fasthttp v1.74.0 github.com/valyala/fasthttp v1.74.0
go.opentelemetry.io/otel v1.47.0 go.opentelemetry.io/otel v1.47.0
+2 -2
View File
@@ -97,8 +97,8 @@ github.com/savsgio/gotils v0.0.0-20250924091648-bce9a52d7761 h1:McifyVxygw1d67y6
github.com/savsgio/gotils v0.0.0-20250924091648-bce9a52d7761/go.mod h1:Vi9gvHvTw4yCUHIznFl5TPULS7aXwgaTByGeBY75Wko= github.com/savsgio/gotils v0.0.0-20250924091648-bce9a52d7761/go.mod h1:Vi9gvHvTw4yCUHIznFl5TPULS7aXwgaTByGeBY75Wko=
github.com/shamaton/msgpack/v3 v3.2.3 h1:0r0aZtrXDFOPpwWJTEOpFq+Ih/JmMLm0pqLN5mSilrw= github.com/shamaton/msgpack/v3 v3.2.3 h1:0r0aZtrXDFOPpwWJTEOpFq+Ih/JmMLm0pqLN5mSilrw=
github.com/shamaton/msgpack/v3 v3.2.3/go.mod h1:sgBYvEiyz8JR1NC3yGRoPVME9xXovpnh3l/plW1nfRo= github.com/shamaton/msgpack/v3 v3.2.3/go.mod h1:sgBYvEiyz8JR1NC3yGRoPVME9xXovpnh3l/plW1nfRo=
github.com/sony/gobreaker v1.0.0 h1:feX5fGGXSl3dYd4aHZItw+FpHLvvoaqkawKjVNiFMNQ= github.com/sony/gobreaker/v2 v2.4.0 h1:g2KJRW1Ubty3+ZOcSEUN7K+REQJdN6yo6XvaML+jptg=
github.com/sony/gobreaker v1.0.0/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/sony/gobreaker/v2 v2.4.0/go.mod h1:pTyFJgcZ3h2tdQVLZZruK2C0eoFL1fb/G83wK1ZQl+s=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+1 -1
View File
@@ -13,7 +13,7 @@ import (
"github.com/gofiber/fiber/v3" "github.com/gofiber/fiber/v3"
libpack_cache "github.com/lukaszraczylo/graphql-monitoring-proxy/cache" libpack_cache "github.com/lukaszraczylo/graphql-monitoring-proxy/cache"
libpack_monitoring "github.com/lukaszraczylo/graphql-monitoring-proxy/monitoring" libpack_monitoring "github.com/lukaszraczylo/graphql-monitoring-proxy/monitoring"
"github.com/sony/gobreaker" "github.com/sony/gobreaker/v2"
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
) )
+4 -4
View File
@@ -23,7 +23,7 @@ import (
libpack_logger "github.com/lukaszraczylo/graphql-monitoring-proxy/logging" libpack_logger "github.com/lukaszraczylo/graphql-monitoring-proxy/logging"
libpack_monitoring "github.com/lukaszraczylo/graphql-monitoring-proxy/monitoring" libpack_monitoring "github.com/lukaszraczylo/graphql-monitoring-proxy/monitoring"
libpack_tracing "github.com/lukaszraczylo/graphql-monitoring-proxy/tracing" libpack_tracing "github.com/lukaszraczylo/graphql-monitoring-proxy/tracing"
"github.com/sony/gobreaker" "github.com/sony/gobreaker/v2"
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
) )
@@ -91,7 +91,7 @@ var circuitBreakerCountWindow = 10 * time.Minute
// Global circuit breaker // Global circuit breaker
var ( var (
cb *gobreaker.CircuitBreaker cb *gobreaker.CircuitBreaker[any]
cbMutex sync.RWMutex cbMutex sync.RWMutex
) )
@@ -240,7 +240,7 @@ func initCircuitBreaker(config *config) {
} }
// Initialize the circuit breaker // Initialize the circuit breaker
cb = gobreaker.NewCircuitBreaker(cbSettings) cb = gobreaker.NewCircuitBreaker[any](cbSettings)
config.Logger.Info(&libpack_logger.LogMessage{ config.Logger.Info(&libpack_logger.LogMessage{
Message: "Circuit breaker initialized", Message: "Circuit breaker initialized",
@@ -530,7 +530,7 @@ func effectiveCircuitBackoff(base time.Duration, multiplier float64, maxBackoff
// allocation- and lock-free on the hot path. now is a parameter (not // allocation- and lock-free on the hot path. now is a parameter (not
// time.Now() read internally) so tests can drive this deterministically // time.Now() read internally) so tests can drive this deterministically
// without wall-clock sleeps. // without wall-clock sleeps.
func circuitBackoffGateBlocks(config *config, breaker *gobreaker.CircuitBreaker, now time.Time) bool { func circuitBackoffGateBlocks(config *config, breaker *gobreaker.CircuitBreaker[any], now time.Time) bool {
trips := cbBackoff.trips() trips := cbBackoff.trips()
if trips <= 0 { if trips <= 0 {
return false return false
+1 -1
View File
@@ -14,7 +14,7 @@ import (
"github.com/gofiber/fiber/v3" "github.com/gofiber/fiber/v3"
libpack_cache "github.com/lukaszraczylo/graphql-monitoring-proxy/cache" libpack_cache "github.com/lukaszraczylo/graphql-monitoring-proxy/cache"
"github.com/sony/gobreaker" "github.com/sony/gobreaker/v2"
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
) )