From 2ef03e24e96b190e1c43c602486a857b16c93664 Mon Sep 17 00:00:00 2001 From: Xiaoxi Chen Date: Thu, 21 Mar 2024 16:34:04 +0800 Subject: [PATCH] Add max_receive_msg_size parameters. max_receive_msg_size default to 4M, which might be too small for some usecases, allow this to be reconfigurable. Signed-off-by: Xiaoxi Chen --- conanfile.py | 2 +- include/sisl/grpc/rpc_server.hpp | 6 ++++-- src/grpc/rpc_server.cpp | 18 ++++++++++++------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/conanfile.py b/conanfile.py index 01cc29a9..20936370 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,7 +9,7 @@ class SISLConan(ConanFile): name = "sisl" - version = "12.0.1" + version = "12.1.1" homepage = "https://github.com/eBay/sisl" description = "Library for fast data structures, utilities" diff --git a/include/sisl/grpc/rpc_server.hpp b/include/sisl/grpc/rpc_server.hpp index e23d1109..c54a3895 100644 --- a/include/sisl/grpc/rpc_server.hpp +++ b/include/sisl/grpc/rpc_server.hpp @@ -41,15 +41,17 @@ class GrpcServer : private boost::noncopyable { const std::string& ssl_cert); GrpcServer(const std::string& listen_addr, uint32_t threads, const std::string& ssl_key, const std::string& ssl_cert, const std::shared_ptr< sisl::GrpcTokenVerifier >& auth_mgr); + GrpcServer(const std::string& listen_addr, uint32_t threads, int max_receive_msg_size, const std::string& ssl_key, + const std::string& ssl_cert, const std::shared_ptr< sisl::GrpcTokenVerifier >& auth_mgr); virtual ~GrpcServer(); /** * Create a new GrpcServer instance and initialize it. */ static GrpcServer* make(const std::string& listen_addr, uint32_t threads = 1, const std::string& ssl_key = "", - const std::string& ssl_cert = ""); + const std::string& ssl_cert = "", int max_receive_msg_size = 0); static GrpcServer* make(const std::string& listen_addr, const std::shared_ptr< sisl::GrpcTokenVerifier >& auth_mgr, - uint32_t threads = 1, const std::string& ssl_key = "", const std::string& ssl_cert = ""); + uint32_t threads = 1, const std::string& ssl_key = "", const std::string& ssl_cert = "", int max_receive_msg_size = 0); void run(const rpc_thread_start_cb_t& thread_start_cb = nullptr); void shutdown(); diff --git a/src/grpc/rpc_server.cpp b/src/grpc/rpc_server.cpp index eed6edea..e7c099b3 100644 --- a/src/grpc/rpc_server.cpp +++ b/src/grpc/rpc_server.cpp @@ -31,13 +31,18 @@ SISL_LOGGING_DEF(grpc_server) namespace sisl { GrpcServer::GrpcServer(const std::string& listen_addr, uint32_t threads, const std::string& ssl_key, const std::string& ssl_cert) : - GrpcServer::GrpcServer(listen_addr, threads, ssl_key, ssl_cert, nullptr) {} - + GrpcServer::GrpcServer(listen_addr, threads, 0, ssl_key, ssl_cert, nullptr) {} GrpcServer::GrpcServer(const std::string& listen_addr, uint32_t threads, const std::string& ssl_key, const std::string& ssl_cert, const std::shared_ptr< sisl::GrpcTokenVerifier >& auth_mgr) : + GrpcServer::GrpcServer(listen_addr, threads, 0, ssl_key, ssl_cert, auth_mgr) {} +GrpcServer::GrpcServer(const std::string& listen_addr, uint32_t threads, int max_receive_msg_size, + const std::string& ssl_key, const std::string& ssl_cert, + const std::shared_ptr< sisl::GrpcTokenVerifier >& auth_mgr) : m_num_threads{threads}, m_auth_mgr{auth_mgr} { if (listen_addr.empty() || threads == 0) { throw std::invalid_argument("Invalid parameter to start grpc server"); } + if (max_receive_msg_size != 0) { m_builder.SetMaxReceiveMessageSize(max_receive_msg_size); } + if (!ssl_cert.empty() && !ssl_key.empty()) { std::string key_contents; std::string cert_contents; @@ -76,13 +81,14 @@ GrpcServer::~GrpcServer() { } GrpcServer* GrpcServer::make(const std::string& listen_addr, uint32_t threads, const std::string& ssl_key, - const std::string& ssl_cert) { - return GrpcServer::make(listen_addr, nullptr, threads, ssl_key, ssl_cert); + const std::string& ssl_cert, int max_receive_msg_size) { + return GrpcServer::make(listen_addr, nullptr, threads, ssl_key, ssl_cert, max_receive_msg_size); } GrpcServer* GrpcServer::make(const std::string& listen_addr, const std::shared_ptr< sisl::GrpcTokenVerifier >& auth_mgr, - uint32_t threads, const std::string& ssl_key, const std::string& ssl_cert) { - return new GrpcServer(listen_addr, threads, ssl_key, ssl_cert, auth_mgr); + uint32_t threads, const std::string& ssl_key, const std::string& ssl_cert, + int max_receive_msg_size) { + return new GrpcServer(listen_addr, threads, max_receive_msg_size, ssl_key, ssl_cert, auth_mgr); } void GrpcServer::run(const rpc_thread_start_cb_t& thread_start_cb) {