diff --git a/trpc/client/service_proxy.h b/trpc/client/service_proxy.h index 4d222a68..3f9eea72 100644 --- a/trpc/client/service_proxy.h +++ b/trpc/client/service_proxy.h @@ -65,10 +65,10 @@ class ServiceProxy { const ClientCodecPtr& GetClientCodec() { return codec_; } /// @brief Stop used resources by service proxy (thread-safe). - void Stop(); + virtual void Stop(); /// @brief Destroy used resources by service proxy (thread-safe). - void Destroy(); + virtual void Destroy(); /// @brief Pre-allocate a connection, used for scenarios that require fixed connections for data transmission /// (thread-safe). @@ -118,9 +118,18 @@ class ServiceProxy { /// in the options for non-direct connection models. const std::string& GetServiceName(); + // Collect statistics on the service proxy and report them to the tvar. + void ProxyStatistics(const ClientContextPtr& ctx); + + // Used to determine if the request has timed out. Returns true if timed out, false if normal. + bool CheckTimeout(const ClientContextPtr& context); + /// @brief Use the proxy option parameters to set the context. void FillClientContext(const ClientContextPtr& context); + // Routing selection interface, retrieve IP and port based on service name and store in ctx. + bool SelectTarget(const ClientContextPtr& context); + /// @brief Run filters by filter point. int RunFilters(const FilterPoint& point, const ClientContextPtr& context); @@ -138,9 +147,6 @@ class ServiceProxy { // Check if the tvar variable required for statistical has been created, and create it if it has not been created. void PrepareStatistics(const std::string& service_name); - // Collect statistics on the service proxy and report them to the tvar. - void ProxyStatistics(const ClientContextPtr& ctx); - // Determine if pipeline is supported. bool SupportPipeline(const std::shared_ptr& option); @@ -156,9 +162,6 @@ class ServiceProxy { // Execute IO tracking for rpcz. FilterStatus RunIoFilters(const FilterPoint& point, const std::any& msg) noexcept; - // Routing selection interface, retrieve IP and port based on service name and store in ctx. - bool SelectTarget(const ClientContextPtr& context); - // Get connection type by config ConnectionType GetClientConnectType(); @@ -169,9 +172,6 @@ class ServiceProxy { // plugin. void InitSelectorFilter(); - // Used to determine if the request has timed out. Returns true if timed out, false if normal. - bool CheckTimeout(const ClientContextPtr& context); - // Error handling, it will set error information to context. void HandleError(const ClientContextPtr& context, int ret, std::string&& err_msg); diff --git a/trpc/client/service_proxy_manager.cc b/trpc/client/service_proxy_manager.cc index cbdfe311..36c60988 100644 --- a/trpc/client/service_proxy_manager.cc +++ b/trpc/client/service_proxy_manager.cc @@ -67,7 +67,7 @@ void ServiceProxyManager::SetOptionDefaultValue(const std::string& name, std::sh if (option->name_space.empty()) { option->name_space = TrpcConfig::GetInstance()->GetGlobalConfig().env_namespace; } - + // If callee_name is not set, set it to name of proxy. if (option->callee_name.empty()) { option->callee_name = name;