Skip to content

Commit 0847a95

Browse files
committed
Migrate from go.uber.org/atomic to sync/atomic
Signed-off-by: Jonathan Halterman <[email protected]>
1 parent e8336a5 commit 0847a95

File tree

5 files changed

+8
-11
lines changed

5 files changed

+8
-11
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ github.com/prometheus/client_golang/prometheus.{DefaultGatherer,DefBuckets,NewUn
6060
github.com/prometheus/client_golang/prometheus.{NewCounter,NewCounterVec,NewCounterVec,NewGauge,NewGaugeVec,NewGaugeFunc,\
6161
NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec}=github.com/prometheus/client_golang/prometheus/promauto.{NewCounter,\
6262
NewCounterVec,NewCounterVec,NewGauge,NewGaugeVec,NewGaugeFunc,NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec},\
63-
sync/atomic=go.uber.org/atomic" ./...
63+
go.uber.org/atomic=sync/atomic" ./...
6464
@$(FAILLINT) -paths "fmt.{Print,Println,Sprint}" -ignore-tests ./...
6565
@echo ">> linting all of the Go files GOGC=${GOGC}"
6666
@$(GOLANGCI_LINT) run

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ require (
2323
github.com/tencentyun/cos-go-sdk-v5 v0.7.40
2424
go.opentelemetry.io/otel v1.16.0
2525
go.opentelemetry.io/otel/trace v1.16.0
26-
go.uber.org/atomic v1.9.0
2726
golang.org/x/oauth2 v0.14.0
2827
golang.org/x/sync v0.5.0
2928
google.golang.org/api v0.150.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,6 @@ go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s=
221221
go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4=
222222
go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs=
223223
go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0=
224-
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
225-
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
226224
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
227225
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
228226
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=

objstore.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ func WrapWithMetrics(b Bucket, reg prometheus.Registerer, name string) *metricBu
430430
ConstLabels: prometheus.Labels{"bucket": name},
431431
Buckets: prometheus.ExponentialBuckets(2<<14, 2, 16), // 32KiB, 64KiB, ... 1GiB
432432
// Use factor=2 for native histograms, which gives similar buckets as the original exponential buckets.
433-
NativeHistogramBucketFactor: 2,
434-
NativeHistogramMaxBucketNumber: 100,
433+
NativeHistogramBucketFactor: 2,
434+
NativeHistogramMaxBucketNumber: 100,
435435
NativeHistogramMinResetDuration: 1 * time.Hour,
436436
}, []string{"operation"}),
437437

@@ -441,8 +441,8 @@ func WrapWithMetrics(b Bucket, reg prometheus.Registerer, name string) *metricBu
441441
ConstLabels: prometheus.Labels{"bucket": name},
442442
Buckets: []float64{0.001, 0.01, 0.1, 0.3, 0.6, 1, 3, 6, 9, 20, 30, 60, 90, 120},
443443
// Use the recommended defaults for native histograms with 10% growth factor.
444-
NativeHistogramBucketFactor: 1.1,
445-
NativeHistogramMaxBucketNumber: 100,
444+
NativeHistogramBucketFactor: 1.1,
445+
NativeHistogramMaxBucketNumber: 100,
446446
NativeHistogramMinResetDuration: 1 * time.Hour,
447447
}, []string{"operation"}),
448448

objstore_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import (
1010
"os"
1111
"path/filepath"
1212
"strings"
13+
"sync/atomic"
1314
"testing"
1415

1516
"github.com/efficientgo/core/testutil"
1617
"github.com/go-kit/log"
1718
"github.com/pkg/errors"
1819
"github.com/prometheus/client_golang/prometheus"
1920
promtest "github.com/prometheus/client_golang/prometheus/testutil"
20-
"go.uber.org/atomic"
2121
)
2222

2323
func TestMetricBucket_Close(t *testing.T) {
@@ -469,7 +469,7 @@ func TestDownloadDir_CleanUp(t *testing.T) {
469469
b := unreliableBucket{
470470
Bucket: NewInMemBucket(),
471471
n: 3,
472-
current: atomic.NewInt32(0),
472+
current: &atomic.Int32{},
473473
}
474474
tempDir := t.TempDir()
475475

@@ -492,7 +492,7 @@ type unreliableBucket struct {
492492
}
493493

494494
func (b unreliableBucket) Get(ctx context.Context, name string) (io.ReadCloser, error) {
495-
if b.current.Inc()%b.n == 0 {
495+
if b.current.Add(1)%b.n == 0 {
496496
return nil, errors.Errorf("some error message")
497497
}
498498
return b.Bucket.Get(ctx, name)

0 commit comments

Comments
 (0)