vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright 2015, Google Inc. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are |
| 8 | * met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * * Redistributions in binary form must reproduce the above |
| 13 | * copyright notice, this list of conditions and the following disclaimer |
| 14 | * in the documentation and/or other materials provided with the |
| 15 | * distribution. |
| 16 | * * Neither the name of Google Inc. nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | * |
| 32 | */ |
| 33 | |
| 34 | #include <forward_list> |
| 35 | #include <functional> |
Vijay Pai | 8ad3209 | 2015-03-23 12:44:28 -0700 | [diff] [blame] | 36 | #include <mutex> |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 37 | #include <sys/time.h> |
| 38 | #include <sys/resource.h> |
| 39 | #include <sys/signal.h> |
| 40 | #include <thread> |
| 41 | |
| 42 | #include <gflags/gflags.h> |
| 43 | #include <grpc/support/alloc.h> |
| 44 | #include <grpc/support/host_port.h> |
| 45 | #include <grpc++/async_unary_call.h> |
| 46 | #include <grpc++/config.h> |
| 47 | #include <grpc++/server.h> |
| 48 | #include <grpc++/server_builder.h> |
| 49 | #include <grpc++/server_context.h> |
Craig Tiller | 61691f9 | 2015-03-02 08:51:52 -0800 | [diff] [blame] | 50 | #include <grpc++/server_credentials.h> |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 51 | #include <grpc++/status.h> |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 52 | #include <grpc++/stream.h> |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 53 | #include <gtest/gtest.h> |
| 54 | #include "src/cpp/server/thread_pool.h" |
| 55 | #include "test/core/util/grpc_profiler.h" |
| 56 | #include "test/cpp/qps/qpstest.pb.h" |
Craig Tiller | d6479d6 | 2015-03-04 12:50:11 -0800 | [diff] [blame] | 57 | #include "test/cpp/qps/server.h" |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 58 | |
| 59 | #include <grpc/grpc.h> |
| 60 | #include <grpc/support/log.h> |
| 61 | |
Craig Tiller | d6479d6 | 2015-03-04 12:50:11 -0800 | [diff] [blame] | 62 | namespace grpc { |
Craig Tiller | a182bf1 | 2015-03-04 13:54:39 -0800 | [diff] [blame] | 63 | namespace testing { |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 64 | |
Craig Tiller | d6479d6 | 2015-03-04 12:50:11 -0800 | [diff] [blame] | 65 | class AsyncQpsServerTest : public Server { |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 66 | public: |
Yang Gao | 6baa9b6 | 2015-03-17 10:49:39 -0700 | [diff] [blame] | 67 | AsyncQpsServerTest(const ServerConfig& config, int port) |
Vijay Pai | 8ad3209 | 2015-03-23 12:44:28 -0700 | [diff] [blame] | 68 | : srv_cq_(), async_service_(&srv_cq_), server_(nullptr), |
| 69 | shutdown_(false) { |
Yang Gao | 6baa9b6 | 2015-03-17 10:49:39 -0700 | [diff] [blame] | 70 | char* server_address = NULL; |
Craig Tiller | d6479d6 | 2015-03-04 12:50:11 -0800 | [diff] [blame] | 71 | gpr_join_host_port(&server_address, "::", port); |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 72 | |
| 73 | ServerBuilder builder; |
Nicolas Noble | cfd6073 | 2015-03-18 16:27:43 -0700 | [diff] [blame] | 74 | builder.AddListeningPort(server_address, InsecureServerCredentials()); |
Craig Tiller | d6479d6 | 2015-03-04 12:50:11 -0800 | [diff] [blame] | 75 | gpr_free(server_address); |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 76 | |
| 77 | builder.RegisterAsyncService(&async_service_); |
| 78 | |
| 79 | server_ = builder.BuildAndStart(); |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 80 | |
| 81 | using namespace std::placeholders; |
| 82 | request_unary_ = std::bind(&TestService::AsyncService::RequestUnaryCall, |
| 83 | &async_service_, _1, _2, _3, &srv_cq_, _4); |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 84 | request_streaming_ = |
| 85 | std::bind(&TestService::AsyncService::RequestStreamingCall, |
| 86 | &async_service_, _1, _2, &srv_cq_, _3); |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 87 | for (int i = 0; i < 100; i++) { |
Vijay Pai | 64ac47f | 2015-02-26 17:59:51 -0800 | [diff] [blame] | 88 | contexts_.push_front( |
| 89 | new ServerRpcContextUnaryImpl<SimpleRequest, SimpleResponse>( |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 90 | request_unary_, ProcessRPC)); |
| 91 | contexts_.push_front( |
| 92 | new ServerRpcContextStreamingImpl<SimpleRequest, SimpleResponse>( |
| 93 | request_streaming_, ProcessRPC)); |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 94 | } |
Craig Tiller | d6479d6 | 2015-03-04 12:50:11 -0800 | [diff] [blame] | 95 | for (int i = 0; i < config.threads(); i++) { |
Vijay Pai | acf6f31 | 2015-03-02 15:13:39 -0800 | [diff] [blame] | 96 | threads_.push_back(std::thread([=]() { |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 97 | // Wait until work is available or we are shutting down |
| 98 | bool ok; |
Yang Gao | 6baa9b6 | 2015-03-17 10:49:39 -0700 | [diff] [blame] | 99 | void* got_tag; |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 100 | while (srv_cq_.Next(&got_tag, &ok)) { |
Vijay Pai | 1da729a | 2015-03-23 12:52:56 -0700 | [diff] [blame^] | 101 | ServerRpcContext* ctx = detag(got_tag); |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 102 | // The tag is a pointer to an RPC context to invoke |
| 103 | if (ctx->RunNextState(ok) == false) { |
| 104 | // this RPC context is done, so refresh it |
Vijay Pai | 8ad3209 | 2015-03-23 12:44:28 -0700 | [diff] [blame] | 105 | std::lock_guard<std::mutex> g(shutdown_mutex_); |
Vijay Pai | 1da729a | 2015-03-23 12:52:56 -0700 | [diff] [blame^] | 106 | if (!shutdown_) { |
Vijay Pai | acf6f31 | 2015-03-02 15:13:39 -0800 | [diff] [blame] | 107 | ctx->Reset(); |
| 108 | } |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 109 | } |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 110 | } |
| 111 | return; |
| 112 | })); |
| 113 | } |
Craig Tiller | d6479d6 | 2015-03-04 12:50:11 -0800 | [diff] [blame] | 114 | } |
| 115 | ~AsyncQpsServerTest() { |
| 116 | server_->Shutdown(); |
Vijay Pai | 8ad3209 | 2015-03-23 12:44:28 -0700 | [diff] [blame] | 117 | { |
| 118 | std::lock_guard<std::mutex> g(shutdown_mutex_); |
| 119 | shutdown_ = true; |
| 120 | srv_cq_.Shutdown(); |
| 121 | } |
Yang Gao | 6baa9b6 | 2015-03-17 10:49:39 -0700 | [diff] [blame] | 122 | for (auto& thr : threads_) { |
Craig Tiller | d6479d6 | 2015-03-04 12:50:11 -0800 | [diff] [blame] | 123 | thr.join(); |
| 124 | } |
| 125 | while (!contexts_.empty()) { |
| 126 | delete contexts_.front(); |
| 127 | contexts_.pop_front(); |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 128 | } |
| 129 | } |
Vijay Pai | 64ac47f | 2015-02-26 17:59:51 -0800 | [diff] [blame] | 130 | |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 131 | private: |
| 132 | class ServerRpcContext { |
Vijay Pai | 64ac47f | 2015-02-26 17:59:51 -0800 | [diff] [blame] | 133 | public: |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 134 | ServerRpcContext() {} |
Vijay Pai | 64ac47f | 2015-02-26 17:59:51 -0800 | [diff] [blame] | 135 | virtual ~ServerRpcContext(){}; |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 136 | virtual bool RunNextState(bool) = 0; // next state, return false if done |
Craig Tiller | a182bf1 | 2015-03-04 13:54:39 -0800 | [diff] [blame] | 137 | virtual void Reset() = 0; // start this back at a clean state |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 138 | }; |
Yang Gao | 6baa9b6 | 2015-03-17 10:49:39 -0700 | [diff] [blame] | 139 | static void* tag(ServerRpcContext* func) { |
| 140 | return reinterpret_cast<void*>(func); |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 141 | } |
Yang Gao | 6baa9b6 | 2015-03-17 10:49:39 -0700 | [diff] [blame] | 142 | static ServerRpcContext* detag(void* tag) { |
| 143 | return reinterpret_cast<ServerRpcContext*>(tag); |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | template <class RequestType, class ResponseType> |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 147 | class ServerRpcContextUnaryImpl GRPC_FINAL : public ServerRpcContext { |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 148 | public: |
| 149 | ServerRpcContextUnaryImpl( |
Yang Gao | 6baa9b6 | 2015-03-17 10:49:39 -0700 | [diff] [blame] | 150 | std::function<void(ServerContext*, RequestType*, |
| 151 | grpc::ServerAsyncResponseWriter<ResponseType>*, |
| 152 | void*)> request_method, |
| 153 | std::function<grpc::Status(const RequestType*, ResponseType*)> |
vjpai | 4e1e1bc | 2015-02-27 23:47:12 -0800 | [diff] [blame] | 154 | invoke_method) |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 155 | : next_state_(&ServerRpcContextUnaryImpl::invoker), |
| 156 | request_method_(request_method), |
| 157 | invoke_method_(invoke_method), |
Vijay Pai | 64ac47f | 2015-02-26 17:59:51 -0800 | [diff] [blame] | 158 | response_writer_(&srv_ctx_) { |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 159 | request_method_(&srv_ctx_, &req_, &response_writer_, |
Vijay Pai | 64ac47f | 2015-02-26 17:59:51 -0800 | [diff] [blame] | 160 | AsyncQpsServerTest::tag(this)); |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 161 | } |
vjpai | 3c11066 | 2015-02-27 07:17:16 -0800 | [diff] [blame] | 162 | ~ServerRpcContextUnaryImpl() GRPC_OVERRIDE {} |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 163 | bool RunNextState(bool ok) GRPC_OVERRIDE {return (this->*next_state_)(ok);} |
vjpai | 5b39f9a | 2015-02-27 09:33:00 -0800 | [diff] [blame] | 164 | void Reset() GRPC_OVERRIDE { |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 165 | srv_ctx_ = ServerContext(); |
| 166 | req_ = RequestType(); |
| 167 | response_writer_ = |
Vijay Pai | 64ac47f | 2015-02-26 17:59:51 -0800 | [diff] [blame] | 168 | grpc::ServerAsyncResponseWriter<ResponseType>(&srv_ctx_); |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 169 | |
| 170 | // Then request the method |
| 171 | next_state_ = &ServerRpcContextUnaryImpl::invoker; |
| 172 | request_method_(&srv_ctx_, &req_, &response_writer_, |
Vijay Pai | 64ac47f | 2015-02-26 17:59:51 -0800 | [diff] [blame] | 173 | AsyncQpsServerTest::tag(this)); |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 174 | } |
Vijay Pai | 64ac47f | 2015-02-26 17:59:51 -0800 | [diff] [blame] | 175 | |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 176 | private: |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 177 | bool finisher(bool) { return false; } |
| 178 | bool invoker(bool ok) { |
| 179 | if (!ok) |
| 180 | return false; |
| 181 | |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 182 | ResponseType response; |
| 183 | |
| 184 | // Call the RPC processing function |
| 185 | grpc::Status status = invoke_method_(&req_, &response); |
| 186 | |
| 187 | // Have the response writer work and invoke on_finish when done |
| 188 | next_state_ = &ServerRpcContextUnaryImpl::finisher; |
Vijay Pai | 64ac47f | 2015-02-26 17:59:51 -0800 | [diff] [blame] | 189 | response_writer_.Finish(response, status, AsyncQpsServerTest::tag(this)); |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 190 | return true; |
| 191 | } |
| 192 | ServerContext srv_ctx_; |
| 193 | RequestType req_; |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 194 | bool (ServerRpcContextUnaryImpl::*next_state_)(bool); |
Yang Gao | 6baa9b6 | 2015-03-17 10:49:39 -0700 | [diff] [blame] | 195 | std::function<void(ServerContext*, RequestType*, |
| 196 | grpc::ServerAsyncResponseWriter<ResponseType>*, void*)> |
vjpai | 4e1e1bc | 2015-02-27 23:47:12 -0800 | [diff] [blame] | 197 | request_method_; |
Yang Gao | 6baa9b6 | 2015-03-17 10:49:39 -0700 | [diff] [blame] | 198 | std::function<grpc::Status(const RequestType*, ResponseType*)> |
vjpai | 4e1e1bc | 2015-02-27 23:47:12 -0800 | [diff] [blame] | 199 | invoke_method_; |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 200 | grpc::ServerAsyncResponseWriter<ResponseType> response_writer_; |
| 201 | }; |
| 202 | |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 203 | template <class RequestType, class ResponseType> |
| 204 | class ServerRpcContextStreamingImpl GRPC_FINAL : public ServerRpcContext { |
| 205 | public: |
| 206 | ServerRpcContextStreamingImpl( |
Vijay Pai | 8ad3209 | 2015-03-23 12:44:28 -0700 | [diff] [blame] | 207 | std::function<void(ServerContext *, |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 208 | grpc::ServerAsyncReaderWriter<ResponseType, |
| 209 | RequestType> *, void *)> request_method, |
| 210 | std::function<grpc::Status(const RequestType *, ResponseType *)> |
| 211 | invoke_method) |
| 212 | : next_state_(&ServerRpcContextStreamingImpl::request_done), |
| 213 | request_method_(request_method), |
| 214 | invoke_method_(invoke_method), |
| 215 | stream_(&srv_ctx_) { |
| 216 | request_method_(&srv_ctx_, &stream_, AsyncQpsServerTest::tag(this)); |
| 217 | } |
| 218 | ~ServerRpcContextStreamingImpl() GRPC_OVERRIDE { |
| 219 | } |
| 220 | bool RunNextState(bool ok) GRPC_OVERRIDE {return (this->*next_state_)(ok);} |
| 221 | void Reset() GRPC_OVERRIDE { |
| 222 | srv_ctx_ = ServerContext(); |
| 223 | req_ = RequestType(); |
| 224 | stream_ = grpc::ServerAsyncReaderWriter<ResponseType, |
| 225 | RequestType>(&srv_ctx_); |
| 226 | |
| 227 | // Then request the method |
| 228 | next_state_ = &ServerRpcContextStreamingImpl::request_done; |
| 229 | request_method_(&srv_ctx_, &stream_, AsyncQpsServerTest::tag(this)); |
| 230 | } |
| 231 | |
| 232 | private: |
| 233 | bool request_done(bool ok) { |
| 234 | if (!ok) |
| 235 | return false; |
| 236 | stream_.Read(&req_, AsyncQpsServerTest::tag(this)); |
| 237 | next_state_ = &ServerRpcContextStreamingImpl::read_done; |
| 238 | return true; |
| 239 | } |
Vijay Pai | 8ad3209 | 2015-03-23 12:44:28 -0700 | [diff] [blame] | 240 | |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 241 | bool read_done(bool ok) { |
| 242 | if (ok) { |
| 243 | // invoke the method |
| 244 | ResponseType response; |
| 245 | // Call the RPC processing function |
| 246 | grpc::Status status = invoke_method_(&req_, &response); |
| 247 | // initiate the write |
| 248 | stream_.Write(response, AsyncQpsServerTest::tag(this)); |
| 249 | next_state_ = &ServerRpcContextStreamingImpl::write_done; |
| 250 | } else { // client has sent writes done |
| 251 | // finish the stream |
| 252 | stream_.Finish(Status::OK, AsyncQpsServerTest::tag(this)); |
| 253 | next_state_ = &ServerRpcContextStreamingImpl::finish_done; |
| 254 | } |
| 255 | return true; |
| 256 | } |
| 257 | bool write_done(bool ok) { |
| 258 | // now go back and get another streaming read! |
| 259 | if (ok) { |
| 260 | stream_.Read(&req_, AsyncQpsServerTest::tag(this)); |
| 261 | next_state_ = &ServerRpcContextStreamingImpl::read_done; |
| 262 | } |
| 263 | else { |
| 264 | stream_.Finish(Status::OK, AsyncQpsServerTest::tag(this)); |
| 265 | next_state_ = &ServerRpcContextStreamingImpl::finish_done; |
| 266 | } |
| 267 | return true; |
| 268 | } |
| 269 | bool finish_done(bool ok) {return false; /* reset the context */ } |
| 270 | |
| 271 | ServerContext srv_ctx_; |
| 272 | RequestType req_; |
| 273 | bool (ServerRpcContextStreamingImpl::*next_state_)(bool); |
| 274 | std::function<void(ServerContext *, |
| 275 | grpc::ServerAsyncReaderWriter<ResponseType, |
| 276 | RequestType> *, void *)> request_method_; |
| 277 | std::function<grpc::Status(const RequestType *, ResponseType *)> |
| 278 | invoke_method_; |
| 279 | grpc::ServerAsyncReaderWriter<ResponseType,RequestType> stream_; |
| 280 | }; |
| 281 | |
Vijay Pai | 1da729a | 2015-03-23 12:52:56 -0700 | [diff] [blame^] | 282 | static Status ProcessRPC(const SimpleRequest* request, |
| 283 | SimpleResponse* response) { |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 284 | if (request->response_size() > 0) { |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 285 | if (!SetPayload(request->response_type(), request->response_size(), |
| 286 | response->mutable_payload())) { |
| 287 | return Status(grpc::StatusCode::INTERNAL, "Error creating payload."); |
| 288 | } |
| 289 | } |
| 290 | return Status::OK; |
| 291 | } |
| 292 | CompletionQueue srv_cq_; |
| 293 | TestService::AsyncService async_service_; |
Vijay Pai | acf6f31 | 2015-03-02 15:13:39 -0800 | [diff] [blame] | 294 | std::vector<std::thread> threads_; |
Craig Tiller | d6479d6 | 2015-03-04 12:50:11 -0800 | [diff] [blame] | 295 | std::unique_ptr<grpc::Server> server_; |
Yang Gao | 6baa9b6 | 2015-03-17 10:49:39 -0700 | [diff] [blame] | 296 | std::function<void(ServerContext*, SimpleRequest*, |
| 297 | grpc::ServerAsyncResponseWriter<SimpleResponse>*, void*)> |
vjpai | 4e1e1bc | 2015-02-27 23:47:12 -0800 | [diff] [blame] | 298 | request_unary_; |
Vijay Pai | 1da729a | 2015-03-23 12:52:56 -0700 | [diff] [blame^] | 299 | std::function<void(ServerContext*, grpc::ServerAsyncReaderWriter< |
| 300 | SimpleResponse,SimpleRequest>*, void*)> |
vjpai | 46f6523 | 2015-03-23 10:10:27 -0700 | [diff] [blame] | 301 | request_streaming_; |
Yang Gao | 6baa9b6 | 2015-03-17 10:49:39 -0700 | [diff] [blame] | 302 | std::forward_list<ServerRpcContext*> contexts_; |
Vijay Pai | 8ad3209 | 2015-03-23 12:44:28 -0700 | [diff] [blame] | 303 | |
| 304 | std::mutex shutdown_mutex_; |
| 305 | bool shutdown_; |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 306 | }; |
| 307 | |
Yang Gao | 6baa9b6 | 2015-03-17 10:49:39 -0700 | [diff] [blame] | 308 | std::unique_ptr<Server> CreateAsyncServer(const ServerConfig& config, |
Craig Tiller | a182bf1 | 2015-03-04 13:54:39 -0800 | [diff] [blame] | 309 | int port) { |
| 310 | return std::unique_ptr<Server>(new AsyncQpsServerTest(config, port)); |
vjpai | dea740f | 2015-02-26 16:35:35 -0800 | [diff] [blame] | 311 | } |
| 312 | |
Craig Tiller | a182bf1 | 2015-03-04 13:54:39 -0800 | [diff] [blame] | 313 | } // namespace testing |
| 314 | } // namespace grpc |