Skip to content

Commit

Permalink
Review comments and deflake e2e test again
Browse files Browse the repository at this point in the history
  • Loading branch information
zasweq committed Aug 10, 2023
1 parent 7aa9a17 commit 0ce88c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 4 additions & 1 deletion balancer/leastrequest/balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func (s) TestLeastRequestPersistsCounts(t *testing.T) {
}(grpcranduint32)
var index int
indexes := []uint32{
0, 1, 2, 3, 4, 5, // Triggers a round robin distribution of indexes for two addresses or three addresses.
0, 0, 1, 1,
}
grpcranduint32 = func() uint32 {
ret := indexes[index%len(indexes)]
Expand Down Expand Up @@ -423,6 +423,9 @@ func (s) TestLeastRequestPersistsCounts(t *testing.T) {
// SubConns. Thus, since address 3 is the new address and the first two
// addresses are populated with RPCs, once the picker update of all 3 READY
// SubConns takes effect, all new streams should be started on address 3.
indexes = []uint32{
0, 1, 2, 3, 4, 5,
}
lrscJSON = `
{
"loadBalancingConfig": [
Expand Down
11 changes: 5 additions & 6 deletions balancer/leastrequest/leastrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var grpcranduint32 = grpcrand.Uint32
// Name is the name of the least request balancer.
const Name = "least_request_experimental"

var logger = grpclog.Component("least request")
var logger = grpclog.Component("least-request")

func init() {
balancer.Register(bb{})
Expand All @@ -47,9 +47,9 @@ func init() {
type LBConfig struct {
serviceconfig.LoadBalancingConfig `json:"-"`

// ChoiceCount is the number of random SubConns to sample to try and find
// the one with the Least Request. If unset, defaults to 2. If set to < 2,
// will become 2, and if set to > 10, will become 10.
// ChoiceCount is the number of random SubConns to sample to find the one
// with the fewest outstanding requests. If unset, defaults to 2. If set to
// < 2, the config will be rejected, and if set to > 10, will become 10.
ChoiceCount uint32 `json:"choiceCount,omitempty"`
}

Expand Down Expand Up @@ -82,8 +82,7 @@ func (bb) Name() string {
func (bb) Build(cc balancer.ClientConn, bOpts balancer.BuildOptions) balancer.Balancer {
b := &leastRequestBalancer{scRPCCounts: make(map[balancer.SubConn]*int32)}
baseBuilder := base.NewBalancerBuilder(Name, b, base.Config{HealthCheck: true})
baseBalancer := baseBuilder.Build(cc, bOpts)
b.Balancer = baseBalancer
b.Balancer = baseBuilder.Build(cc, bOpts)
return b
}

Expand Down

0 comments on commit 0ce88c9

Please sign in to comment.