| 318 | }); |
| 319 | } |
| 320 | void BaseRunner::initialize_http_server(td::Promise<td::Unit> promise) { |
| 321 | if (http_port_ > 0) { |
| 322 | class Cb : public http::HttpCallback { |
| 323 | public: |
| 324 | Cb(td::actor::ActorId<BaseRunner> client, td::actor::Scheduler *scheduler) |
| 325 | : client_(std::move(client)), scheduler_(scheduler) { |
| 326 | } |
| 327 | void receive_request(http::HttpCallback::RequestType request_type, |
| 328 | std::vector<std::pair<std::string, std::string>> headers, std::string path, |
| 329 | std::vector<std::pair<std::string, std::string>> args, std::string body, |
| 330 | std::unique_ptr<http::HttpRequestCallback> answer_callback) override { |
| 331 | CHECK(answer_callback); |
| 332 | scheduler_->run_in_context([&]() { |
| 333 | td::actor::send_closure_later(client_, &BaseRunner::receive_http_request_outer, request_type, |
| 334 | std::move(headers), std::move(path), std::move(args), std::move(body), |
| 335 | std::move(answer_callback)); |
| 336 | }); |
| 337 | } |
| 338 | |
| 339 | private: |
| 340 | td::actor::ActorId<BaseRunner> client_; |
| 341 | td::actor::Scheduler *scheduler_; |
| 342 | }; |
| 343 | |
| 344 | http::init_http_server(http_port_, std::make_shared<Cb>(actor_id(this), scheduler_)); |
| 345 | } |
| 346 | promise.set_value(td::Unit()); |
| 347 | } |
| 348 | void BaseRunner::http_server_initialized() { |
| 349 | initialize_rpc_server([self_id = actor_id(this)](td::Result<td::Unit> R) { |
| 350 | if (R.is_error()) { |
nothing calls this directly
no test coverage detected