@@ -21,7 +21,8 @@ import (
2121 "math"
2222 "slices"
2323
24- "github.com/nexcode/rpcplatform/internal/attributes"
24+ "github.com/nexcode/rpcplatform/internal/config"
25+ "github.com/nexcode/rpcplatform/internal/grpcattrs"
2526 "google.golang.org/grpc/balancer"
2627 "google.golang.org/grpc/balancer/base"
2728)
@@ -34,12 +35,18 @@ type connInfo struct {
3435 count int
3536}
3637
37- func (pb * pickerBuilder ) makeConnInfo (pickerInfo base.PickerBuildInfo ) ([]* connInfo , int ) {
38+ func (* pickerBuilder ) makeConnInfo (pickerInfo base.PickerBuildInfo ) ([]* connInfo , int ) {
3839 connInfoArr := make ([]* connInfo , 0 , len (pickerInfo .ReadySCs ))
40+
3941 var totalWeight int
42+ var config * config.Client
4043
4144 for subConn , subConnInfo := range pickerInfo .ReadySCs {
42- attributes := subConnInfo .Address .Attributes .Value (struct {}{}).(* attributes.Attributes )
45+ if config == nil {
46+ config = grpcattrs .GetClientConfig (subConnInfo .Address .Attributes )
47+ }
48+
49+ attributes := grpcattrs .GetAttributes (subConnInfo .Address .Attributes )
4350
4451 if attributes .BalancerWeight <= 0 {
4552 continue
@@ -56,8 +63,8 @@ func (pb *pickerBuilder) makeConnInfo(pickerInfo base.PickerBuildInfo) ([]*connI
5663 return cmp .Compare (b .priority , a .priority )
5764 })
5865
59- if pb . maxActiveServers > 0 && pb . maxActiveServers < len (connInfoArr ) {
60- connInfoArr = connInfoArr [:pb . maxActiveServers ]
66+ if config . MaxActiveServers > 0 && config . MaxActiveServers < len (connInfoArr ) {
67+ connInfoArr = connInfoArr [:config . MaxActiveServers ]
6168 }
6269
6370 for _ , connInfo := range connInfoArr {
0 commit comments