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

kafka: move processing loop into connect context #8135

Merged
merged 3 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions src/v/kafka/server/connection_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ using namespace std::chrono_literals;

namespace kafka {

ss::future<> connection_context::process() {
while (true) {
if (is_finished_parsing()) {
break;
}
co_await process_one_request();
}
}

ss::future<> connection_context::process_one_request() {
auto sz = co_await parse_size(conn->input());
if (!sz.has_value()) {
Expand Down
1 change: 1 addition & 0 deletions src/v/kafka/server/connection_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class connection_context final
return authorized;
}

ss::future<> process();
ss::future<> process_one_request();
bool is_finished_parsing() const;
ss::net::inet_address client_host() const { return _client_addr; }
Expand Down
13 changes: 6 additions & 7 deletions src/v/kafka/server/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ ss::future<> server::apply(ss::lw_shared_ptr<net::connection> conn) {
mtls_state,
config::shard_local_cfg().kafka_request_max_bytes.bind());

co_return co_await ss::do_until(
[ctx] { return ctx->is_finished_parsing(); },
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: is_finished_parsing() can be private now

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed can ya reapprove?

[ctx] { return ctx->process_one_request(); })
.handle_exception([ctx, authn_method](std::exception_ptr eptr) {
try {
co_await ctx->process();
} catch (...) {
auto eptr = std::current_exception();
auto disconnected = net::is_disconnect_exception(eptr);
if (authn_method == config::broker_authn_method::sasl) {
/*
Expand Down Expand Up @@ -269,9 +269,8 @@ ss::future<> server::apply(ss::lw_shared_ptr<net::connection> conn) {
eptr);
}
}
return ss::make_exception_future(eptr);
})
.finally([ctx] {});
std::rethrow_exception(eptr);
}
}

template<>
Expand Down