Reuse query client in scale tests
It was previously not reusing it, so the clients would leak over time.
@@ -104,8 +104,15 @@ func getQueryServiceGRPCClient() pb.QueryServiceClient {
}
func queryPoolsWrapper(mmf func(req *pb.MatchProfile, pools map[string][]*pb.Ticket) ([]*pb.Match, error)) matchFunction {
+ var q pb.QueryServiceClient
+ var startQ sync.Once
+
return func(req *pb.RunRequest, stream pb.MatchFunction_RunServer) error {
- poolTickets, err := matchfunction.QueryPools(stream.Context(), getQueryServiceGRPCClient(), req.GetProfile().GetPools())
+ startQ.Do(func() {
+ q = getQueryServiceGRPCClient()
+ })
+
+ poolTickets, err := matchfunction.QueryPools(stream.Context(), q, req.GetProfile().GetPools())
if err != nil {
return err
}
