Skip to content

Commit 3409a56

Browse files
authored
cleanup: rename fields for clarity (#8043)
1 parent b0e2ae9 commit 3409a56

File tree

6 files changed

+171
-169
lines changed

6 files changed

+171
-169
lines changed

Diff for: clientconn.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func NewClient(target string, opts ...DialOption) (conn *ClientConn, err error)
181181
}
182182
cc.dopts.defaultServiceConfig, _ = scpr.Config.(*ServiceConfig)
183183
}
184-
cc.mkp = cc.dopts.copts.KeepaliveParams
184+
cc.keepaliveParams = cc.dopts.copts.KeepaliveParams
185185

186186
if err = cc.initAuthority(); err != nil {
187187
return nil, err
@@ -623,7 +623,7 @@ type ClientConn struct {
623623
balancerWrapper *ccBalancerWrapper // Always recreated whenever entering idle to simplify Close.
624624
sc *ServiceConfig // Latest service config received from the resolver.
625625
conns map[*addrConn]struct{} // Set to nil on close.
626-
mkp keepalive.ClientParameters // May be updated upon receipt of a GoAway.
626+
keepaliveParams keepalive.ClientParameters // May be updated upon receipt of a GoAway.
627627
// firstResolveEvent is used to track whether the name resolver sent us at
628628
// least one update. RPCs block on this event. May be accessed without mu
629629
// if we know we cannot be asked to enter idle mode while accessing it (e.g.
@@ -1215,8 +1215,8 @@ func (ac *addrConn) adjustParams(r transport.GoAwayReason) {
12151215
case transport.GoAwayTooManyPings:
12161216
v := 2 * ac.dopts.copts.KeepaliveParams.Time
12171217
ac.cc.mu.Lock()
1218-
if v > ac.cc.mkp.Time {
1219-
ac.cc.mkp.Time = v
1218+
if v > ac.cc.keepaliveParams.Time {
1219+
ac.cc.keepaliveParams.Time = v
12201220
}
12211221
ac.cc.mu.Unlock()
12221222
}
@@ -1312,7 +1312,7 @@ func (ac *addrConn) tryAllAddrs(ctx context.Context, addrs []resolver.Address, c
13121312
ac.mu.Lock()
13131313

13141314
ac.cc.mu.RLock()
1315-
ac.dopts.copts.KeepaliveParams = ac.cc.mkp
1315+
ac.dopts.copts.KeepaliveParams = ac.cc.keepaliveParams
13161316
ac.cc.mu.RUnlock()
13171317

13181318
copts := ac.dopts.copts

Diff for: clientconn_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ func (s) TestClientUpdatesParamsAfterGoAway(t *testing.T) {
753753
for {
754754
time.Sleep(10 * time.Millisecond)
755755
cc.mu.RLock()
756-
v := cc.mkp.Time
756+
v := cc.keepaliveParams.Time
757757
cc.mu.RUnlock()
758758
if v == 20*time.Second {
759759
// Success

Diff for: dialoptions.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ type dialOptions struct {
7373
chainUnaryInts []UnaryClientInterceptor
7474
chainStreamInts []StreamClientInterceptor
7575

76-
cp Compressor
76+
compressorV0 Compressor
7777
dc Decompressor
7878
bs internalbackoff.Strategy
7979
block bool
@@ -258,7 +258,7 @@ func WithCodec(c Codec) DialOption {
258258
// Deprecated: use UseCompressor instead. Will be supported throughout 1.x.
259259
func WithCompressor(cp Compressor) DialOption {
260260
return newFuncDialOption(func(o *dialOptions) {
261-
o.cp = cp
261+
o.compressorV0 = cp
262262
})
263263
}
264264

Diff for: rpc_util.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (d *gzipDecompressor) Type() string {
151151

152152
// callInfo contains all related configuration and information about an RPC.
153153
type callInfo struct {
154-
compressorType string
154+
compressorName string
155155
failFast bool
156156
maxReceiveMessageSize *int
157157
maxSendMessageSize *int
@@ -222,7 +222,7 @@ type HeaderCallOption struct {
222222

223223
func (o HeaderCallOption) before(*callInfo) error { return nil }
224224
func (o HeaderCallOption) after(_ *callInfo, attempt *csAttempt) {
225-
*o.HeaderAddr, _ = attempt.s.Header()
225+
*o.HeaderAddr, _ = attempt.transportStream.Header()
226226
}
227227

228228
// Trailer returns a CallOptions that retrieves the trailer metadata
@@ -244,7 +244,7 @@ type TrailerCallOption struct {
244244

245245
func (o TrailerCallOption) before(*callInfo) error { return nil }
246246
func (o TrailerCallOption) after(_ *callInfo, attempt *csAttempt) {
247-
*o.TrailerAddr = attempt.s.Trailer()
247+
*o.TrailerAddr = attempt.transportStream.Trailer()
248248
}
249249

250250
// Peer returns a CallOption that retrieves peer information for a unary RPC.
@@ -266,7 +266,7 @@ type PeerCallOption struct {
266266

267267
func (o PeerCallOption) before(*callInfo) error { return nil }
268268
func (o PeerCallOption) after(_ *callInfo, attempt *csAttempt) {
269-
if x, ok := peer.FromContext(attempt.s.Context()); ok {
269+
if x, ok := peer.FromContext(attempt.transportStream.Context()); ok {
270270
*o.PeerAddr = *x
271271
}
272272
}
@@ -435,7 +435,7 @@ type CompressorCallOption struct {
435435
}
436436

437437
func (o CompressorCallOption) before(c *callInfo) error {
438-
c.compressorType = o.CompressorType
438+
c.compressorName = o.CompressorType
439439
return nil
440440
}
441441
func (o CompressorCallOption) after(*callInfo, *csAttempt) {}

Diff for: server.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -1645,10 +1645,10 @@ func (s *Server) processStreamingRPC(ctx context.Context, stream *transport.Serv
16451645
// If dc is set and matches the stream's compression, use it. Otherwise, try
16461646
// to find a matching registered compressor for decomp.
16471647
if rc := stream.RecvCompress(); s.opts.dc != nil && s.opts.dc.Type() == rc {
1648-
ss.dc = s.opts.dc
1648+
ss.decompressorV0 = s.opts.dc
16491649
} else if rc != "" && rc != encoding.Identity {
1650-
ss.decomp = encoding.GetCompressor(rc)
1651-
if ss.decomp == nil {
1650+
ss.decompressorV1 = encoding.GetCompressor(rc)
1651+
if ss.decompressorV1 == nil {
16521652
st := status.Newf(codes.Unimplemented, "grpc: Decompressor is not installed for grpc-encoding %q", rc)
16531653
ss.s.WriteStatus(st)
16541654
return st.Err()
@@ -1660,12 +1660,12 @@ func (s *Server) processStreamingRPC(ctx context.Context, stream *transport.Serv
16601660
//
16611661
// NOTE: this needs to be ahead of all handling, https://github.com/grpc/grpc-go/issues/686.
16621662
if s.opts.cp != nil {
1663-
ss.cp = s.opts.cp
1663+
ss.compressorV0 = s.opts.cp
16641664
ss.sendCompressorName = s.opts.cp.Type()
16651665
} else if rc := stream.RecvCompress(); rc != "" && rc != encoding.Identity {
16661666
// Legacy compressor not specified; attempt to respond with same encoding.
1667-
ss.comp = encoding.GetCompressor(rc)
1668-
if ss.comp != nil {
1667+
ss.compressorV1 = encoding.GetCompressor(rc)
1668+
if ss.compressorV1 != nil {
16691669
ss.sendCompressorName = rc
16701670
}
16711671
}
@@ -1676,7 +1676,7 @@ func (s *Server) processStreamingRPC(ctx context.Context, stream *transport.Serv
16761676
}
16771677
}
16781678

1679-
ss.ctx = newContextWithRPCInfo(ss.ctx, false, ss.codec, ss.cp, ss.comp)
1679+
ss.ctx = newContextWithRPCInfo(ss.ctx, false, ss.codec, ss.compressorV0, ss.compressorV1)
16801680

16811681
if trInfo != nil {
16821682
trInfo.tr.LazyLog(&trInfo.firstLine, false)

0 commit comments

Comments
 (0)