From 487dc58dae695a153e9545c40e9cc8e3f29f913f Mon Sep 17 00:00:00 2001 From: rizesql Date: Tue, 28 May 2024 08:00:56 +0300 Subject: [PATCH] better --- src/api/wrapper.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/api/wrapper.h b/src/api/wrapper.h index 7a76290..44baa30 100644 --- a/src/api/wrapper.h +++ b/src/api/wrapper.h @@ -14,14 +14,14 @@ namespace api { template class Wrapper { private: - std::unique_ptr rpc_; + Impl rpc_; typename Impl::service_t service_; public: template::value, int> = 0> explicit Wrapper(Args &&... args) : - rpc_(std::make_unique(std::forward(args)...)), + rpc_(std::forward(args)...), service_(*this) {} template @@ -30,8 +30,7 @@ namespace api { spdlog::info("[RPC {}] - START", log::label(service_.name())); auto begin = std::chrono::steady_clock::now(); - auto service = dynamic_cast(rpc_.get()); - auto res = service->template call(ctx, req); + auto res = rpc_.template call(ctx, req); auto end = std::chrono::steady_clock::now(); auto elapsed = std::chrono::duration_cast(end - begin); @@ -41,7 +40,7 @@ namespace api { return res; } catch (...) { - auto s = rpc_->exception(); + auto s = rpc_.exception(); std::string data; s.SerializeToString(&data);