diff --git a/tools/relay/server.go b/tools/relay/server.go index 50bf5b591..470527760 100644 --- a/tools/relay/server.go +++ b/tools/relay/server.go @@ -61,6 +61,10 @@ var ( value = flag.String("value", "helloWorld", "String input to pass to benchmark") functionMethod = flag.String("function-method", "default", "Which method of benchmark to invoke") + clientReqRecv = 0 + funcInvSuccess = 0 + funcInvFail = 0 + // Client grpcClient grpcClients.GrpcClient inputGenerator grpcClients.Generator @@ -77,6 +81,11 @@ func isDebuggingEnabled() bool { } } +func printStats() { + log.Printf("Client Requests: %d", clientReqRecv) + log.Printf("Function Invocations: %d successful, %d fail", funcInvSuccess, funcInvFail) +} + func main() { flag.Parse() @@ -139,17 +148,29 @@ func main() { log.Printf("Started relay server at %s", *address) if err := grpcServer.Serve(listener); err != nil { - log.Fatalf("failed to serve: %v", err) + log.Fatalf("Failed to serve: %v", err) } } func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { - log.Info("Received from invoker: ", in.GetName()) + log.Debug("Received from invoker: ", in.GetName()) + clientReqRecv++ + + if clientReqRecv%100 == 0 { + printStats() + } // Create new packet pkt := inputGenerator.Next() log.Debug("Send to func: ", pkt) - reply := grpcClient.Request(ctx, pkt) + reply, err := grpcClient.Request(ctx, pkt) + if err != nil { + log.Warnf("Failed to send request to function: %v\n", err) + funcInvFail++ + return nil, err + } + + funcInvSuccess++ log.Debug("Recv from func: ", reply) return &pb.HelloReply{Message: reply}, nil