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

asio_service support stream mode #527

Merged
merged 6 commits into from
Aug 16, 2024
Merged

Conversation

ZZhongge
Copy link
Contributor

  1. set TCP_NODELAY = true this can be set after the socket open. So we can't set it in constructor. (async_connect will open the socket)
  2. does the order of calling all the when_done matter when error occur? in write path when_done(error triggered) -> close_socket(in destructor) in read path close_socket(directly call) -> when_done(error triggered)
  3. keep the old path for all request if stream_mode_ = false

already addressed all the comment.

1. set TCP_NODELAY = true this can be set after the socket open. So we can't set it in constructor. (async_connect will open the socket)
2. does the order of calling all the when_done matter when error occur? in write path when_done(error triggered) -> close_socket(in destructor) in read path close_socket(directly call) -> when_done(error triggered)
3. keep the old path for all request if stream_mode_ = false

already addressed all the comment.
Comment on lines 161 to 172
ptr<req_msg> get_req() {
return req;
}

rpc_handler& get_when_done() {
return when_done;
}

uint64_t get_timeout_ms() {
return timeout_ms;
}
private:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is struct. Remove these functions and directly access members.

@@ -150,6 +150,31 @@ asio_service::meta_cb_params req_to_params(req_msg* req, resp_msg* resp) {

// === ASIO Abstraction ===
// (to switch SSL <-> unsecure on-the-fly)
struct pending_req_pkg {
public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.

Comment on lines 173 to 175
ptr<req_msg> req;
rpc_handler when_done;
uint64_t timeout_ms;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming convention for member variables is using _ suffix: req_, when_done_, and timeout_ms_.

Comment on lines 1169 to 1170
rpc_handler& when_done,
uint64_t send_timeout_ms) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent.

Comment on lines 1184 to 1185
rpc_handler& when_done,
uint64_t send_timeout_ms) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent.

// handle read queue in reverse
{
auto_lock(pending_read_reqs_lock_);
for (auto rit = pending_read_reqs_.rbegin(); rit != pending_read_reqs_.rend(); ++rit) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Comment on lines 35 to 44
add_executable(asio_service_stream_test
unit/asio_service_stream_test.cxx
${EXAMPLES_SRC}/logger.cc
${EXAMPLES_SRC}/in_memory_log_store.cxx)
add_dependencies(asio_service_stream_test
static_lib
build_ssl_key)
target_link_libraries(asio_service_stream_test
${BUILD_DIR}/${LIBRARY_OUTPUT_NAME}
${LIBRARIES})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent.

Comment on lines 152 to 161
int my_id;
int port;
std::atomic<ulong> response_log_index;
ulong send_log_index = 0;
ptr<asio_service> asio_svc;
ptr<rpc_client> my_client;
ptr<rpc_listener> my_listener;
ptr<logger_wrapper> my_log_wrapper;
ptr<logger> my_log;
ptr<stream_msg_handler> my_msg_handler;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use _ suffix for all member variable names.

Comment on lines 116 to 118
SimpleLogger* ll = my_log_wrapper->getLogger();
_log_info(ll, "resp log index not match, resp: %ld, current: %ld",
resp->get_next_idx(), get_next_log_index());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the whole point of this test (checking whether request and response are delivered in order). Rather than leaving a log, there should be a boolean flag to set if failure happens, and check CHK_FALSE at the end.

Copy link
Contributor Author

@ZZhongge ZZhongge Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If entering into this branch, this response_log_index will not increase. So it will fail at CHK_EQ(count, s.get_resp_log_index());. Those logs are just for debugging purpose.

Comment on lines 64 to 66
SimpleLogger* ll = my_log_wrapper->getLogger();
_log_info(ll, "req log index not match, req: %ld, current: %ld",
req.get_last_log_idx(), streamed_log_index.load());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto, it should set a boolean flag and make test failed.

@greensky00
Copy link
Contributor

Also, can you add

  pull_request:
    branches:
      - master
      - streaming

into .github/workflow/cmake.yml? in order to trigger PR validation for this branch.

@greensky00 greensky00 merged commit 680fbdf into eBay:streaming Aug 16, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants