Skip to content

Commit 4282fd5

Browse files
committed
rpc_util: various cleanups
1 parent 614c2c9 commit 4282fd5

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

experimental/shared_buffer_pool_test.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,11 @@ func (s) TestRecvBufferPoolStream(t *testing.T) {
6868
FullDuplexCallF: func(stream testgrpc.TestService_FullDuplexCallServer) error {
6969
for i := 0; i < reqCount; i++ {
7070
preparedMsg := &grpc.PreparedMsg{}
71-
err := preparedMsg.Encode(stream, &testgrpc.StreamingOutputCallResponse{
71+
if err := preparedMsg.Encode(stream, &testgrpc.StreamingOutputCallResponse{
7272
Payload: &testgrpc.Payload{
7373
Body: []byte{'0' + uint8(i)},
7474
},
75-
})
76-
if err != nil {
75+
}); err != nil {
7776
return err
7877
}
7978
stream.SendMsg(preparedMsg)
@@ -83,7 +82,6 @@ func (s) TestRecvBufferPoolStream(t *testing.T) {
8382
}
8483

8584
pool := &checkBufferPool{}
86-
8785
sopts := []grpc.ServerOption{experimental.RecvBufferPool(pool)}
8886
dopts := []grpc.DialOption{experimental.WithRecvBufferPool(pool)}
8987
if err := ss.Start(sopts, dopts...); err != nil {
@@ -96,7 +94,7 @@ func (s) TestRecvBufferPoolStream(t *testing.T) {
9694

9795
stream, err := ss.Client.FullDuplexCall(ctx, tc.callOpts...)
9896
if err != nil {
99-
t.Fatalf("ss.Client.FullDuplexCall failed: %f", err)
97+
t.Fatalf("ss.Client.FullDuplexCall failed: %v", err)
10098
}
10199

102100
var ngot int
@@ -160,7 +158,6 @@ func (s) TestRecvBufferPoolUnary(t *testing.T) {
160158
}
161159

162160
pool := &checkBufferPool{}
163-
164161
sopts := []grpc.ServerOption{experimental.RecvBufferPool(pool)}
165162
dopts := []grpc.DialOption{experimental.WithRecvBufferPool(pool)}
166163
if err := ss.Start(sopts, dopts...); err != nil {
@@ -173,17 +170,16 @@ func (s) TestRecvBufferPoolUnary(t *testing.T) {
173170

174171
const reqCount = 10
175172
for i := 0; i < reqCount; i++ {
176-
_, err := ss.Client.UnaryCall(
173+
if _, err := ss.Client.UnaryCall(
177174
ctx,
178175
&testgrpc.SimpleRequest{
179176
Payload: &testgrpc.Payload{
180177
Body: make([]byte, largeSize),
181178
},
182179
},
183180
tc.callOpts...,
184-
)
185-
if err != nil {
186-
t.Fatalf("ss.Client.UnaryCall failed: %f", err)
181+
); err != nil {
182+
t.Fatalf("ss.Client.UnaryCall failed: %v", err)
187183
}
188184
}
189185

rpc_util.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,8 @@ func decompress(compressor encoding.Compressor, d []byte, maxReceiveMessageSize
795795
// will read more data if available.
796796
// +MinRead so ReadFrom will not reallocate if size is correct.
797797
//
798-
// TODO: If we ensure that the buffer size is the same as the DecompressedSize, we can also utilize the recv buffer pool here.
798+
// TODO: If we ensure that the buffer size is the same as the DecompressedSize,
799+
// we can also utilize the recv buffer pool here.
799800
buf := bytes.NewBuffer(make([]byte, 0, size+bytes.MinRead))
800801
bytesRead, err := buf.ReadFrom(io.LimitReader(dcReader, int64(maxReceiveMessageSize)+1))
801802
return buf.Bytes(), int(bytesRead), err

0 commit comments

Comments
 (0)