Skip to content

Commit

Permalink
Add max_receive_msg_size parameters.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
xiaoxichen committed Mar 21, 2024
1 parent 675770c commit bff9768
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class SISLConan(ConanFile):
name = "sisl"
version = "11.1.8"
version = "11.1.9"

homepage = "https://github.com/eBay/sisl"
description = "Library for fast data structures, utilities"
Expand Down
6 changes: 4 additions & 2 deletions include/sisl/grpc/rpc_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
18 changes: 12 additions & 6 deletions src/grpc/rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit bff9768

Please sign in to comment.