Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add send response API that accepts io blob list #224

Merged
merged 2 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.6"
version = "11.1.7"

homepage = "https://github.com/eBay/sisl"
description = "Library for fast data structures, utilities"
Expand Down
1 change: 1 addition & 0 deletions include/sisl/grpc/generic_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class GenericRpcData : public RpcDataAbstract, sisl::ObjLifeCounter< GenericRpcD
void enqueue_call_request(::grpc::ServerCompletionQueue& cq) override;

void send_response();
void send_response(io_blob_list_t const& response_blob_list);
yamingk marked this conversation as resolved.
Show resolved Hide resolved

void set_context(generic_rpc_ctx_ptr ctx);
GenericRpcContextBase* get_context();
Expand Down
4 changes: 4 additions & 0 deletions src/grpc/generic_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ void GenericRpcData::enqueue_call_request(::grpc::ServerCompletionQueue& cq) {
}

void GenericRpcData::send_response() { m_stream.Write(m_response, static_cast< void* >(m_buf_write_tag.ref())); }
void GenericRpcData::send_response(io_blob_list_t const& response_blob_list) {
serialize_to_byte_buffer(response_blob_list, m_response);
send_response();
}

void GenericRpcData::set_context(generic_rpc_ctx_ptr ctx) { m_rpc_context = std::move(ctx); }

Expand Down
15 changes: 10 additions & 5 deletions src/grpc/tests/function/echo_async_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ class TestServer {
std::atomic< uint32_t > num_completions = 0ul;

template < typename BufT >
static void set_response(BufT const& req, grpc::ByteBuffer& resp) {
static void set_response(BufT const& req, grpc::ByteBuffer& resp, bool set_buf) {
DataMessage cli_request;
DeserializeFromBuffer(req, cli_request);
RELEASE_ASSERT((cli_request.m_buf == GENERIC_CLIENT_MESSAGE), "Could not parse response buffer");
SerializeToByteBuffer(resp, cli_request);
if (set_buf) { SerializeToByteBuffer(resp, cli_request); }
}

public:
Expand All @@ -390,12 +390,17 @@ class TestServer {
if ((++num_calls % 2) == 0) {
LOGDEBUGMOD(grpc_server, "respond async generic request, call_num {}", num_calls.load());
std::thread([this, rpc = rpc_data] {
set_response(rpc->request_blob(), rpc->response());
rpc->send_response();
if ((num_calls % 3) == 0) {
set_response(rpc->request_blob(), rpc->response(), false);
rpc->send_response(io_blob_list_t{rpc->request_blob()});
} else {
set_response(rpc->request_blob(), rpc->response(), true);
rpc->send_response();
}
}).detach();
return false;
}
set_response(rpc_data->request(), rpc_data->response());
set_response(rpc_data->request(), rpc_data->response(), true);
return true;
});
RELEASE_ASSERT(res, "register generic rpc failed");
Expand Down
Loading