(clients []testgrpc.TestServiceClient, ticker *time.Ticker)
| 501 | } |
| 502 | |
| 503 | func sendRPCs(clients []testgrpc.TestServiceClient, ticker *time.Ticker) { |
| 504 | var i int |
| 505 | for range ticker.C { |
| 506 | // Get and increment request ID, and save a list of watchers that are |
| 507 | // interested in this RPC. |
| 508 | mu.Lock() |
| 509 | savedRequestID := currentRequestID |
| 510 | currentRequestID++ |
| 511 | savedWatchers := []*statsWatcher{} |
| 512 | for key, value := range watchers { |
| 513 | if key.startID <= savedRequestID && savedRequestID < key.endID { |
| 514 | savedWatchers = append(savedWatchers, value) |
| 515 | } |
| 516 | } |
| 517 | mu.Unlock() |
| 518 | |
| 519 | // Get the RPC metadata configurations from the Configure RPC. |
| 520 | cfgs := rpcCfgs.Load().([]*rpcConfig) |
| 521 | |
| 522 | c := clients[i] |
| 523 | for _, cfg := range cfgs { |
| 524 | go func(cfg *rpcConfig) { |
| 525 | p, info, err := makeOneRPC(c, cfg) |
| 526 | |
| 527 | for _, watcher := range savedWatchers { |
| 528 | // This sends an empty string if the RPC failed. |
| 529 | watcher.chanHosts <- info |
| 530 | } |
| 531 | if err != nil && *failOnFailedRPC && hasRPCSucceeded() { |
| 532 | logger.Fatalf("RPC failed: %v", err) |
| 533 | } |
| 534 | if err == nil { |
| 535 | setRPCSucceeded() |
| 536 | } |
| 537 | if *printResponse { |
| 538 | if err == nil { |
| 539 | if cfg.typ == unaryCall { |
| 540 | // Need to keep this format, because some tests are |
| 541 | // relying on stdout. |
| 542 | fmt.Printf("Greeting: Hello world, this is %s, from %v\n", info.hostname, p.Addr) |
| 543 | } else { |
| 544 | fmt.Printf("RPC %q, from host %s, addr %v\n", cfg.typ, info.hostname, p.Addr) |
| 545 | } |
| 546 | } else { |
| 547 | fmt.Printf("RPC %q, failed with %v\n", cfg.typ, err) |
| 548 | } |
| 549 | } |
| 550 | }(cfg) |
| 551 | } |
| 552 | i = (i + 1) % len(clients) |
| 553 | } |
| 554 | } |
no test coverage detected