makeClients returns a gRPC client (or multiple clients) for the grpc.testing.BenchmarkService service. The client is configured using the different options in the passed 'bf'. Also returns a cleanup function to close the client and release resources.
(bf stats.Features)
| 315 | // 'bf'. Also returns a cleanup function to close the client and release |
| 316 | // resources. |
| 317 | func makeClients(bf stats.Features) ([]testgrpc.BenchmarkServiceClient, func()) { |
| 318 | nw := &latency.Network{Kbps: bf.Kbps, Latency: bf.Latency, MTU: bf.MTU} |
| 319 | opts := []grpc.DialOption{} |
| 320 | sopts := []grpc.ServerOption{} |
| 321 | if bf.ModeCompressor == compModeNop { |
| 322 | sopts = append(sopts, |
| 323 | grpc.RPCCompressor(nopCompressor{}), |
| 324 | grpc.RPCDecompressor(nopDecompressor{}), |
| 325 | ) |
| 326 | opts = append(opts, |
| 327 | grpc.WithCompressor(nopCompressor{}), |
| 328 | grpc.WithDecompressor(nopDecompressor{}), |
| 329 | ) |
| 330 | } |
| 331 | if bf.ModeCompressor == compModeGzip { |
| 332 | opts = append(opts, |
| 333 | grpc.WithDefaultCallOptions(grpc.UseCompressor(gzip.Name)), |
| 334 | ) |
| 335 | } |
| 336 | if bf.EnableKeepalive { |
| 337 | sopts = append(sopts, |
| 338 | grpc.KeepaliveParams(keepalive.ServerParameters{ |
| 339 | Time: keepaliveTime, |
| 340 | Timeout: keepaliveTimeout, |
| 341 | }), |
| 342 | grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ |
| 343 | MinTime: keepaliveMinTime, |
| 344 | PermitWithoutStream: true, |
| 345 | }), |
| 346 | ) |
| 347 | opts = append(opts, |
| 348 | grpc.WithKeepaliveParams(keepalive.ClientParameters{ |
| 349 | Time: keepaliveTime, |
| 350 | Timeout: keepaliveTimeout, |
| 351 | PermitWithoutStream: true, |
| 352 | }), |
| 353 | ) |
| 354 | } |
| 355 | if bf.ClientReadBufferSize >= 0 { |
| 356 | opts = append(opts, grpc.WithReadBufferSize(bf.ClientReadBufferSize)) |
| 357 | } |
| 358 | if bf.ClientWriteBufferSize >= 0 { |
| 359 | opts = append(opts, grpc.WithWriteBufferSize(bf.ClientWriteBufferSize)) |
| 360 | } |
| 361 | if bf.ServerReadBufferSize >= 0 { |
| 362 | sopts = append(sopts, grpc.ReadBufferSize(bf.ServerReadBufferSize)) |
| 363 | } |
| 364 | if bf.SharedWriteBuffer { |
| 365 | opts = append(opts, grpc.WithSharedWriteBuffer(true)) |
| 366 | sopts = append(sopts, grpc.SharedWriteBuffer(true)) |
| 367 | } |
| 368 | if bf.ServerWriteBufferSize >= 0 { |
| 369 | sopts = append(sopts, grpc.WriteBufferSize(bf.ServerWriteBufferSize)) |
| 370 | } |
| 371 | switch bf.RecvBufferPool { |
| 372 | case recvBufferPoolNil: |
| 373 | useNopBufferPool.Store(true) |
| 374 | case recvBufferPoolSimple: |
no test coverage detected