Skip to content

Commit 3370198

Browse files
authored
build(deps): migrate to github.com/ccoveille/go-safecast v2 (#2685)
1 parent dcdd22b commit 3370198

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+126
-99
lines changed

e2e/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ require (
3939
github.com/aws/aws-sdk-go-v2/service/sts v1.39.0 // indirect
4040
github.com/aws/smithy-go v1.23.1 // indirect
4141
github.com/benbjohnson/clock v1.3.5 // indirect
42-
github.com/ccoveille/go-safecast v1.8.1 // indirect
42+
github.com/ccoveille/go-safecast/v2 v2.0.0 // indirect
4343
github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d // indirect
4444
github.com/creasty/defaults v1.8.0 // indirect
4545
github.com/dave/jennifer v1.7.1 // indirect

e2e/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,8 +1425,8 @@ github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl
14251425
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
14261426
github.com/brianvoe/gofakeit/v6 v6.28.0 h1:Xib46XXuQfmlLS2EXRuJpqcw8St6qSZz75OUo0tgAW4=
14271427
github.com/brianvoe/gofakeit/v6 v6.28.0/go.mod h1:Xj58BMSnFqcn/fAQeSK+/PLtC5kSb7FJIq4JyGa8vEs=
1428-
github.com/ccoveille/go-safecast v1.8.1 h1:RoucjfYKKcx2lFmIjRjuo8AeX9k/GaZn5SUMHlA3kMw=
1429-
github.com/ccoveille/go-safecast v1.8.1/go.mod h1:QqwNjxQ7DAqY0C721OIO9InMk9zCwcsO7tnRuHytad8=
1428+
github.com/ccoveille/go-safecast/v2 v2.0.0 h1:+5eyITXAUj3wMjad6cRVJKGnC7vDS55zk0INzJagub0=
1429+
github.com/ccoveille/go-safecast/v2 v2.0.0/go.mod h1:JIYA4CAR33blIDuE6fSwCp2sz1oOBahXnvmdBhOAABs=
14301430
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
14311431
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
14321432
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ require (
4242
github.com/benbjohnson/clock v1.3.5
4343
github.com/bits-and-blooms/bloom/v3 v3.7.1
4444
github.com/caio/go-tdigest/v4 v4.1.0
45-
github.com/ccoveille/go-safecast v1.8.1
45+
github.com/ccoveille/go-safecast/v2 v2.0.0
4646
github.com/cenkalti/backoff/v4 v4.3.0
4747
github.com/cespare/xxhash/v2 v2.3.0
4848
github.com/cloudspannerecosystem/spanner-change-streams-tail v0.3.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,8 +1530,8 @@ github.com/catenacyber/perfsprint v0.9.1 h1:5LlTp4RwTooQjJCvGEFV6XksZvWE7wCOUvjD
15301530
github.com/catenacyber/perfsprint v0.9.1/go.mod h1:q//VWC2fWbcdSLEY1R3l8n0zQCDPdE4IjZwyY1HMunM=
15311531
github.com/ccojocar/zxcvbn-go v1.0.4 h1:FWnCIRMXPj43ukfX000kvBZvV6raSxakYr1nzyNrUcc=
15321532
github.com/ccojocar/zxcvbn-go v1.0.4/go.mod h1:3GxGX+rHmueTUMvm5ium7irpyjmm7ikxYFOSJB21Das=
1533-
github.com/ccoveille/go-safecast v1.8.1 h1:RoucjfYKKcx2lFmIjRjuo8AeX9k/GaZn5SUMHlA3kMw=
1534-
github.com/ccoveille/go-safecast v1.8.1/go.mod h1:QqwNjxQ7DAqY0C721OIO9InMk9zCwcsO7tnRuHytad8=
1533+
github.com/ccoveille/go-safecast/v2 v2.0.0 h1:+5eyITXAUj3wMjad6cRVJKGnC7vDS55zk0INzJagub0=
1534+
github.com/ccoveille/go-safecast/v2 v2.0.0/go.mod h1:JIYA4CAR33blIDuE6fSwCp2sz1oOBahXnvmdBhOAABs=
15351535
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
15361536
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
15371537
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=

internal/datastore/common/changes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"slices"
88
"sort"
99

10-
"github.com/ccoveille/go-safecast"
10+
"github.com/ccoveille/go-safecast/v2"
1111
"google.golang.org/protobuf/types/known/structpb"
1212

1313
log "github.com/authzed/spicedb/internal/logging"

internal/datastore/crdb/crdb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
"github.com/IBM/pgxpoolprometheus"
1414
sq "github.com/Masterminds/squirrel"
15-
"github.com/ccoveille/go-safecast"
15+
"github.com/ccoveille/go-safecast/v2"
1616
"github.com/jackc/pgx/v5"
1717
"github.com/jackc/pgx/v5/pgconn"
1818
"github.com/jackc/pgx/v5/pgxpool"

internal/datastore/crdb/pool/balancer.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"strconv"
1111
"time"
1212

13-
"github.com/ccoveille/go-safecast"
13+
"github.com/ccoveille/go-safecast/v2"
1414
"github.com/jackc/pgx/v5"
1515
"github.com/jackc/pgx/v5/pgxpool"
1616
"github.com/prometheus/client_golang/prometheus"
@@ -87,13 +87,17 @@ type nodeConnectionBalancer[P balancePoolConn[C], C balanceConn] struct {
8787
// testing purposes. Callers should use the exported NewNodeConnectionBalancer.
8888
func newNodeConnectionBalancer[P balancePoolConn[C], C balanceConn](pool balanceablePool[P, C], healthTracker *NodeHealthTracker, interval time.Duration) *nodeConnectionBalancer[P, C] {
8989
seed := int64(0)
90+
var err error
9091
for seed == 0 {
91-
// Sum64 returns a uint64, and safecast will return 0 if it's not castable,
92+
// Sum64 returns a uint64, and safecast will return an error if it's not castable,
9293
// which will happen about half the time (?). We just keep running it until
9394
// we get a seed that fits in the box.
9495
// Subtracting math.MaxInt64 should mean that we retain the entire range of
9596
// possible values.
96-
seed, _ = safecast.Convert[int64](new(maphash.Hash).Sum64() - math.MaxInt64)
97+
seed, err = safecast.Convert[int64](new(maphash.Hash).Sum64() - math.MaxInt64)
98+
if err != nil {
99+
seed = 0
100+
}
97101
}
98102
return &nodeConnectionBalancer[P, C]{
99103
ticker: time.NewTicker(interval),
@@ -159,8 +163,8 @@ func (p *nodeConnectionBalancer[P, C]) mustPruneConnections(ctx context.Context)
159163

160164
// It's highly unlikely that we'll ever have an overflow in
161165
// this context, so we cast directly.
162-
nodeCount, _ := safecast.Convert[uint32](p.healthTracker.HealthyNodeCount())
163-
if nodeCount == 0 {
166+
nodeCount, err := safecast.Convert[uint32](p.healthTracker.HealthyNodeCount())
167+
if err != nil || nodeCount == 0 {
164168
nodeCount = 1
165169
}
166170

internal/datastore/crdb/pool/pool.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"sync"
99
"time"
1010

11-
"github.com/ccoveille/go-safecast"
11+
"github.com/ccoveille/go-safecast/v2"
1212
"github.com/jackc/pgx/v5"
1313
"github.com/jackc/pgx/v5/pgconn"
1414
"github.com/jackc/pgx/v5/pgxpool"
@@ -156,14 +156,20 @@ func (p *RetryPool) ID() string {
156156
// MaxConns returns the MaxConns configured on the underlying pool
157157
func (p *RetryPool) MaxConns() uint32 {
158158
// This should be non-negative
159-
maxConns, _ := safecast.Convert[uint32](p.pool.Config().MaxConns)
159+
maxConns, err := safecast.Convert[uint32](p.pool.Config().MaxConns)
160+
if err != nil {
161+
maxConns = 0
162+
}
160163
return maxConns
161164
}
162165

163166
// MinConns returns the MinConns configured on the underlying pool
164167
func (p *RetryPool) MinConns() uint32 {
165168
// This should be non-negative
166-
minConns, _ := safecast.Convert[uint32](p.pool.Config().MinConns)
169+
minConns, err := safecast.Convert[uint32](p.pool.Config().MinConns)
170+
if err != nil {
171+
minConns = 0
172+
}
167173
return minConns
168174
}
169175

internal/datastore/crdb/readwrite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"fmt"
88

99
sq "github.com/Masterminds/squirrel"
10-
"github.com/ccoveille/go-safecast"
10+
"github.com/ccoveille/go-safecast/v2"
1111
"github.com/jackc/pgx/v5"
1212

1313
v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"

internal/datastore/crdb/stats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"slices"
77

88
"github.com/Masterminds/squirrel"
9-
"github.com/ccoveille/go-safecast"
9+
"github.com/ccoveille/go-safecast/v2"
1010
"github.com/jackc/pgx/v5"
1111
"github.com/rs/zerolog/log"
1212

0 commit comments

Comments
 (0)