diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2016-06-16 17:59:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-16 17:59:39 -0700 |
commit | ef03e53938fddd430e9d6255f1a7f52646c21ef6 (patch) | |
tree | c922abba26c7756d8305eb65660088b79870f0a8 /test | |
parent | bd8d64a778aff40cba4b7b203619150e3ac6175f (diff) | |
parent | 509246f59bb82432caf2ce5f16cf6f96c6ff3899 (diff) |
Merge pull request #6858 from makdharma/issue5851
implement interval_us functionality
Diffstat (limited to 'test')
-rw-r--r-- | test/cpp/interop/server_main.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/cpp/interop/server_main.cc b/test/cpp/interop/server_main.cc index bbedda14d2..062857f3d6 100644 --- a/test/cpp/interop/server_main.cc +++ b/test/cpp/interop/server_main.cc @@ -181,6 +181,14 @@ class TestServiceImpl : public TestService::Service { response.mutable_payload())) { return Status(grpc::StatusCode::INTERNAL, "Error creating payload."); } + int time_us; + if ((time_us = request->response_parameters(i).interval_us()) > 0) { + // Sleep before response if needed + gpr_timespec sleep_time = + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(time_us, GPR_TIMESPAN)); + gpr_sleep_until(sleep_time); + } write_success = writer->Write(response); } if (write_success) { @@ -218,6 +226,14 @@ class TestServiceImpl : public TestService::Service { response.mutable_payload()->set_type(request.payload().type()); response.mutable_payload()->set_body( grpc::string(request.response_parameters(0).size(), '\0')); + int time_us; + if ((time_us = request.response_parameters(0).interval_us()) > 0) { + // Sleep before response if needed + gpr_timespec sleep_time = + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(time_us, GPR_TIMESPAN)); + gpr_sleep_until(sleep_time); + } write_success = stream->Write(response); } } |