Skip to content

Commit 6b71586

Browse files
committed
fix linting
1 parent 66c2bb8 commit 6b71586

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

balancer/balancer.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ func (b *Balancer) Get(ctx context.Context, key []byte) (*prototypes.GetResponse
133133
offlineAddressesErr.Errors = append(offlineAddressesErr.Errors, err)
134134

135135
// TODO: consider tombstoning before removing
136-
rangeView.RemovePartition(rangeView.Addresses[i])
136+
err := rangeView.RemovePartition(rangeView.Addresses[i])
137+
if err != nil {
138+
return nil, err
139+
}
137140
}
138141
}
139142
continue

client/client_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
)
1313

1414
var (
15-
// zero = uint64(0)
1615
one = uint64(1)
1716
)
1817

partition/2pc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ func (ls *ListenServer) PrepareCommit(ctx context.Context, req *pbpartition.Prep
2222

2323
func (ls *ListenServer) AbortCommit(ctx context.Context, req *pbpartition.AbortCommitRequest) (*pbpartition.AbortCommitResponse, error) {
2424
ls.lockedMessage = nil
25-
ls.Partition.ProcessBacklog()
25+
err := ls.Partition.ProcessBacklog()
2626

2727
ls.EventHandler.Emit(TwoPCAbortEvent{})
28-
return &pbpartition.AbortCommitResponse{}, nil
28+
return &pbpartition.AbortCommitResponse{}, err
2929
}
3030

3131
func (ls *ListenServer) Commit(ctx context.Context, req *pbpartition.CommitRequest) (res *pbpartition.CommitResponse, err error) {

partition/grpc.go

+18-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import (
1313

1414
// Set sets a value for a key.
1515
func (ls *ListenServer) Set(ctx context.Context, req *prototypes.SetRequest) (resp *prototypes.SetResponse, err error) {
16-
defer func() { ls.postCRUD(err, req.String()) }()
16+
defer func() {
17+
if ls.postCRUD(err, req.String()) != nil {
18+
panic("postCRUD failed")
19+
}
20+
}()
1721

1822
// note: if request is not valid, the timestamp will not be incremented
1923
// TODO: investigate if it is a valid behaviour.
@@ -49,7 +53,11 @@ func (ls *ListenServer) Set(ctx context.Context, req *prototypes.SetRequest) (re
4953

5054
// Get gets a value for a key.
5155
func (ls *ListenServer) Get(ctx context.Context, req *prototypes.GetRequest) (resp *prototypes.GetResponse, err error) {
52-
defer func() { ls.postCRUD(err, req.String()) }()
56+
defer func() {
57+
if ls.postCRUD(err, req.String()) != nil {
58+
panic("postCRUD failed")
59+
}
60+
}()
5361

5462
if err = req.Validate(); err != nil {
5563
return nil, err
@@ -86,7 +94,11 @@ func (ls *ListenServer) Get(ctx context.Context, req *prototypes.GetRequest) (re
8694

8795
// Delete deletes a value for a key.
8896
func (ls *ListenServer) Delete(ctx context.Context, req *prototypes.DeleteRequest) (resp *prototypes.DeleteResponse, err error) {
89-
defer func() { ls.postCRUD(err, req.String()) }()
97+
defer func() {
98+
if ls.postCRUD(err, req.String()) != nil {
99+
panic("postCRUD failed")
100+
}
101+
}()
90102

91103
if err = req.Validate(); err != nil {
92104
return nil, err
@@ -134,20 +146,20 @@ func (ls *ListenServer) SetHashrange(ctx context.Context, req *prototypes.SetHas
134146
}
135147

136148
// postCRUD runs functionality that should be run after every CRUD operation.
137-
func (ls *ListenServer) postCRUD(err error, req string) {
149+
func (ls *ListenServer) postCRUD(err error, req string) error {
138150
// if error is a warning, log it as warning
139151
// log error as error otherwise
140152
if err != nil {
141153
if eventError, ok := err.(shared.IsWarningEventError); ok {
142154
ls.EventHandler.Emit(eventError.WarningErrorToEvent(req))
143-
return
155+
return nil
144156
}
145157
ls.EventHandler.Emit(shared.ErrorEvent{Req: req, Err: err})
146158
} else {
147159
ls.IncrTs()
148160
}
149161

150-
ls.ProcessBacklog()
162+
return ls.ProcessBacklog()
151163
}
152164

153165
func (ls *ListenServer) validateTSGrpcLevel(ts uint64, message proto.Message) error {

testutil/grpc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ func BalancerClientWith2Partitions(t *testing.T) (net.Addr, func()) {
116116

117117
// register partitions
118118
b := balancer.NewBalancer(balancer.BalancerDBPath+t.Name(), 2)
119-
b.RegisterPartition(ctx, addrs[0].String())
120-
b.RegisterPartition(ctx, addrs[1].String())
119+
_ = b.RegisterPartition(ctx, addrs[0].String())
120+
_ = b.RegisterPartition(ctx, addrs[1].String())
121121

122122
server := balancer.RegisterBalancerServer(b)
123123
_, addr := shared.StartListeningOnPort(server, 0)

0 commit comments

Comments
 (0)