Skip to content

Commit e5aa3fc

Browse files
committed
Fix lint
Signed-off-by: SungJin1212 <[email protected]>
1 parent e65e3a4 commit e5aa3fc

File tree

8 files changed

+23
-27
lines changed

8 files changed

+23
-27
lines changed

Diff for: pkg/cortex/modules_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/weaveworks/common/server"
1414

1515
"github.com/cortexproject/cortex/pkg/cortexpb"
16-
"github.com/cortexproject/cortex/pkg/cortexpbv2"
1716
)
1817

1918
func changeTargetConfig(c *Config) {
@@ -161,7 +160,7 @@ func TestCortex_InitRulerStorage(t *testing.T) {
161160

162161
type myPusher struct{}
163162

164-
func (p *myPusher) PushV2(ctx context.Context, req *cortexpbv2.WriteRequest) (*cortexpbv2.WriteResponse, error) {
163+
func (p *myPusher) PushV2(ctx context.Context, req *cortexpb.WriteRequestV2) (*cortexpb.WriteResponseV2, error) {
165164
return nil, nil
166165
}
167166

Diff for: pkg/cortexpb/slicesPool.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type byteSlicePools struct {
1313
pools []sync.Pool
1414
}
1515

16-
func NewSlicePool(pools int) *byteSlicePools {
16+
func newSlicePool(pools int) *byteSlicePools {
1717
sp := byteSlicePools{}
1818
sp.init(pools)
1919
return &sp
@@ -32,7 +32,7 @@ func (sp *byteSlicePools) init(pools int) {
3232
}
3333
}
3434

35-
func (sp *byteSlicePools) GetSlice(size int) *[]byte {
35+
func (sp *byteSlicePools) getSlice(size int) *[]byte {
3636
index := int(math.Ceil(math.Log2(float64(size)))) - minPoolSizePower
3737

3838
if index >= len(sp.pools) {
@@ -50,7 +50,7 @@ func (sp *byteSlicePools) GetSlice(size int) *[]byte {
5050
return s
5151
}
5252

53-
func (sp *byteSlicePools) ReuseSlice(s *[]byte) {
53+
func (sp *byteSlicePools) reuseSlice(s *[]byte) {
5454
index := int(math.Floor(math.Log2(float64(cap(*s))))) - minPoolSizePower
5555

5656
if index >= len(sp.pools) || index < 0 {

Diff for: pkg/cortexpb/slicesPool_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ import (
99
)
1010

1111
func TestFuzzyByteSlicePools(t *testing.T) {
12-
sut := NewSlicePool(20)
12+
sut := newSlicePool(20)
1313
maxByteSize := int(math.Pow(2, 20+minPoolSizePower-1))
1414

1515
for i := 0; i < 1000; i++ {
1616
size := rand.Int() % maxByteSize
17-
s := sut.GetSlice(size)
17+
s := sut.getSlice(size)
1818
assert.Equal(t, len(*s), size)
19-
sut.ReuseSlice(s)
19+
sut.reuseSlice(s)
2020
}
2121
}
2222

2323
func TestReturnSliceSmallerThanMin(t *testing.T) {
24-
sut := NewSlicePool(20)
24+
sut := newSlicePool(20)
2525
size := 3
2626
buff := make([]byte, 0, size)
27-
sut.ReuseSlice(&buff)
28-
buff2 := sut.GetSlice(size * 2)
27+
sut.reuseSlice(&buff)
28+
buff2 := sut.getSlice(size * 2)
2929
assert.Equal(t, len(*buff2), size*2)
3030
}

Diff for: pkg/cortexpb/timeseries.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var (
4747
}
4848
},
4949
}
50-
bytePool = NewSlicePool(20)
50+
bytePool = newSlicePool(20)
5151
)
5252

5353
// PreallocConfig configures how structures will be preallocated to optimise
@@ -86,7 +86,7 @@ func (p *PreallocTimeseries) Unmarshal(dAtA []byte) error {
8686

8787
func (p *PreallocWriteRequest) Marshal() (dAtA []byte, err error) {
8888
size := p.Size()
89-
p.data = bytePool.GetSlice(size)
89+
p.data = bytePool.getSlice(size)
9090
dAtA = *p.data
9191
n, err := p.MarshalToSizedBuffer(dAtA[:size])
9292
if err != nil {
@@ -97,7 +97,7 @@ func (p *PreallocWriteRequest) Marshal() (dAtA []byte, err error) {
9797

9898
func ReuseWriteRequest(req *PreallocWriteRequest) {
9999
if req.data != nil {
100-
bytePool.ReuseSlice(req.data)
100+
bytePool.reuseSlice(req.data)
101101
req.data = nil
102102
}
103103
req.Source = 0

Diff for: pkg/cortexpb/timeseriesv2.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var (
3434
}
3535
},
3636
}
37-
bytePoolV2 = NewSlicePool(20)
37+
bytePoolV2 = newSlicePool(20)
3838
)
3939

4040
// PreallocWriteRequestV2 is a WriteRequest which preallocs slices on Unmarshal.
@@ -51,7 +51,7 @@ func (p *PreallocWriteRequestV2) Unmarshal(dAtA []byte) error {
5151

5252
func (p *PreallocWriteRequestV2) Marshal() (dAtA []byte, err error) {
5353
size := p.Size()
54-
p.data = bytePool.GetSlice(size)
54+
p.data = bytePool.getSlice(size)
5555
dAtA = *p.data
5656
n, err := p.MarshalToSizedBuffer(dAtA[:size])
5757
if err != nil {
@@ -73,7 +73,7 @@ func (p *PreallocTimeseriesV2) Unmarshal(dAtA []byte) error {
7373

7474
func ReuseWriteRequestV2(req *PreallocWriteRequestV2) {
7575
if req.data != nil {
76-
bytePoolV2.ReuseSlice(req.data)
76+
bytePoolV2.reuseSlice(req.data)
7777
req.data = nil
7878
}
7979
req.Source = 0

Diff for: pkg/ingester/client/cortex_mock_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ import (
66
"github.com/stretchr/testify/mock"
77

88
"github.com/cortexproject/cortex/pkg/cortexpb"
9-
"github.com/cortexproject/cortex/pkg/cortexpbv2"
109
)
1110

1211
type IngesterServerMock struct {
1312
mock.Mock
1413
}
1514

16-
func (m *IngesterServerMock) PushV2(ctx context.Context, r *cortexpbv2.WriteRequest) (*cortexpbv2.WriteResponse, error) {
15+
func (m *IngesterServerMock) PushV2(ctx context.Context, r *cortexpb.WriteRequestV2) (*cortexpb.WriteResponseV2, error) {
1716
args := m.Called(ctx, r)
18-
return args.Get(0).(*cortexpbv2.WriteResponse), args.Error(1)
17+
return args.Get(0).(*cortexpb.WriteResponseV2), args.Error(1)
1918
}
2019

2120
func (m *IngesterServerMock) Push(ctx context.Context, r *cortexpb.WriteRequest) (*cortexpb.WriteResponse, error) {

Diff for: pkg/ruler/compat_test.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,19 @@ import (
2323
"github.com/weaveworks/common/httpgrpc"
2424

2525
"github.com/cortexproject/cortex/pkg/cortexpb"
26-
"github.com/cortexproject/cortex/pkg/cortexpbv2"
2726
"github.com/cortexproject/cortex/pkg/querier/stats"
2827
"github.com/cortexproject/cortex/pkg/util/validation"
2928
)
3029

3130
type fakePusher struct {
3231
request *cortexpb.WriteRequest
33-
requestV2 *cortexpbv2.WriteRequest
32+
requestV2 *cortexpb.WriteRequestV2
3433
response *cortexpb.WriteResponse
35-
responseV2 *cortexpbv2.WriteResponse
34+
responseV2 *cortexpb.WriteResponseV2
3635
err error
3736
}
3837

39-
func (p *fakePusher) PushV2(ctx context.Context, r *cortexpbv2.WriteRequest) (*cortexpbv2.WriteResponse, error) {
38+
func (p *fakePusher) PushV2(ctx context.Context, r *cortexpb.WriteRequestV2) (*cortexpb.WriteResponseV2, error) {
4039
p.requestV2 = r
4140
return p.responseV2, p.err
4241
}

Diff for: pkg/ruler/pusher_mock_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/stretchr/testify/mock"
77

88
"github.com/cortexproject/cortex/pkg/cortexpb"
9-
"github.com/cortexproject/cortex/pkg/cortexpbv2"
109
)
1110

1211
type pusherMock struct {
@@ -17,9 +16,9 @@ func newPusherMock() *pusherMock {
1716
return &pusherMock{}
1817
}
1918

20-
func (m *pusherMock) PushV2(ctx context.Context, req *cortexpbv2.WriteRequest) (*cortexpbv2.WriteResponse, error) {
19+
func (m *pusherMock) PushV2(ctx context.Context, req *cortexpb.WriteRequestV2) (*cortexpb.WriteResponseV2, error) {
2120
args := m.Called(ctx, req)
22-
return args.Get(0).(*cortexpbv2.WriteResponse), args.Error(1)
21+
return args.Get(0).(*cortexpb.WriteResponseV2), args.Error(1)
2322
}
2423

2524
func (m *pusherMock) Push(ctx context.Context, req *cortexpb.WriteRequest) (*cortexpb.WriteResponse, error) {

0 commit comments

Comments
 (0)