Skip to content

Commit 3d25d45

Browse files
committed
fix linter errors, remove UnmarshalJSON method from LB config
1 parent 74a6ec0 commit 3d25d45

File tree

3 files changed

+3
-19
lines changed

3 files changed

+3
-19
lines changed

balancer/deterministicsubsetting/balancer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ func (b *subsettingBalancer) prepareChildResolverState(s resolver.State) resolve
101101
addresses[i], addresses[j] = addresses[j], addresses[i]
102102
})
103103

104-
subsetId := clientIndex % subsetCount
104+
subsetID := clientIndex % subsetCount
105105

106-
start := int(subsetId * int(b.cfg.SubsetSize))
106+
start := int(subsetID * int(b.cfg.SubsetSize))
107107
end := start + int(b.cfg.SubsetSize)
108108

109109
b.logger.Infof("resulting subset: %v", addresses[start:end])

balancer/deterministicsubsetting/config.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
package deterministicsubsetting
2020

2121
import (
22-
"encoding/json"
23-
2422
iserviceconfig "google.golang.org/grpc/internal/serviceconfig"
2523
"google.golang.org/grpc/serviceconfig"
2624
)
@@ -35,17 +33,3 @@ type LBConfig struct {
3533

3634
ChildPolicy *iserviceconfig.BalancerConfig `json:"child_policy,omitempty"`
3735
}
38-
39-
// For UnmarshalJSON to work correctly and set defaults without infinite
40-
// recursion.
41-
type lbConfig LBConfig
42-
43-
func (lbc *LBConfig) UnmarshalJSON(j []byte) error {
44-
// Default top layer values.
45-
lbc.SubsetSize = 10
46-
// Unmarshal JSON on a type with zero values for methods, including
47-
// UnmarshalJSON. Overwrites defaults, leaves alone if not. typecast to
48-
// avoid infinite recursion by not recalling this function and causing stack
49-
// overflow.
50-
return json.Unmarshal(j, (*lbConfig)(lbc))
51-
}

balancer/deterministicsubsetting/e2e_test/subsetting_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func checkRoundRobinRPCs(t *testing.T, ctx context.Context, clients []testgrpc.T
141141
} else if _, ok := m[clientIdx]; !ok {
142142
m[clientIdx] = struct{}{}
143143
} else {
144-
// The backend recieves a second request from the same client. This could happen if the client have 1 backend in READY
144+
// The backend receives a second request from the same client. This could happen if the client have 1 backend in READY
145145
// state while the other are CONNECTING. In this case round_robbin will pick the same address twice.
146146
// We are going to retry after short timeout.
147147
time.Sleep(10 * time.Microsecond)

0 commit comments

Comments
 (0)