MCPcopy
hub / github.com/grpc/grpc-go / sendRPCs

Function sendRPCs

interop/xds/client/client.go:503–554  ·  view source on GitHub ↗
(clients []testgrpc.TestServiceClient, ticker *time.Ticker)

Source from the content-addressed store, hash-verified

501}
502
503func 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}

Callers 1

mainFunction · 0.85

Calls 8

makeOneRPCFunction · 0.85
hasRPCSucceededFunction · 0.85
setRPCSucceededFunction · 0.85
FatalfMethod · 0.65
PrintfMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
LoadMethod · 0.45

Tested by

no test coverage detected