Skip to content

Commit

Permalink
Use local numConnections
Browse files Browse the repository at this point in the history
  • Loading branch information
rjlaine committed May 14, 2024
1 parent 299e2f8 commit e926da5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
33 changes: 18 additions & 15 deletions go/vt/vtgateproxy/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ func (r *JSONGateResolver) Close() {
}

type JSONGateResolverBuilder struct {
jsonPath string
addressField string
portField string
poolTypeField string
affinityField string
affinityValue string
jsonPath string
addressField string
portField string
poolTypeField string
affinityField string
affinityValue string
numConnections int

mu sync.RWMutex
targets map[string][]targetHost
Expand Down Expand Up @@ -105,15 +106,17 @@ func RegisterJSONGateResolver(
poolTypeField string,
affinityField string,
affinityValue string,
numConnections int,
) (*JSONGateResolverBuilder, error) {
jsonDiscovery := &JSONGateResolverBuilder{
targets: map[string][]targetHost{},
jsonPath: jsonPath,
addressField: addressField,
portField: portField,
poolTypeField: poolTypeField,
affinityField: affinityField,
affinityValue: affinityValue,
targets: map[string][]targetHost{},
jsonPath: jsonPath,
addressField: addressField,
portField: portField,
poolTypeField: poolTypeField,
affinityField: affinityField,
affinityValue: affinityValue,
numConnections: numConnections,
}

resolver.Register(jsonDiscovery)
Expand Down Expand Up @@ -293,8 +296,8 @@ func (b *JSONGateResolverBuilder) parse() (bool, error) {
return b.affinityValue == targets[poolType][i].Affinity
})
}
if len(targets[poolType]) > *numConnections {
targets[poolType] = targets[poolType][:*numConnections]
if len(targets[poolType]) > b.numConnections {
targets[poolType] = targets[poolType][:b.numConnections]
}
targetCount.Set(poolType, int64(len(targets[poolType])))
}
Expand Down
1 change: 1 addition & 0 deletions go/vt/vtgateproxy/vtgateproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,6 @@ func Init() {
*poolTypeField,
*affinityField,
*affinityValue,
*numConnections,
)
}

0 comments on commit e926da5

Please sign in to comment.