Skip to content

Commit

Permalink
cloud_storage_client: accept templatized logger
Browse files Browse the repository at this point in the history
This is to allow passing in a `retry_chain_logger` which does not
inherit from `ss::logger` but wraps it.
  • Loading branch information
pgellert committed Nov 7, 2024
1 parent f8b9ed5 commit f388831
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/v/cloud_storage_clients/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ redpanda_cc_library(
"//src/v/utils:functional",
"//src/v/utils:log_hist",
"//src/v/utils:named_type",
"//src/v/utils:retry_chain_node",
"//src/v/utils:stop_signal",
"@boost//:beast",
"@boost//:lexical_cast",
Expand Down
9 changes: 8 additions & 1 deletion src/v/cloud_storage_clients/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "base/vlog.h"
#include "bytes/streambuf.h"
#include "net/connection.h"
#include "utils/retry_chain_node.h"

#include <boost/property_tree/xml_parser.hpp>

Expand All @@ -39,8 +40,9 @@ bool has_abort_or_gate_close_exception(const ss::nested_exception& ex) {
|| is_abort_or_gate_close_exception(ex.outer);
}

template<typename Logger>
error_outcome handle_client_transport_error(
std::exception_ptr current_exception, ss::logger& logger) {
std::exception_ptr current_exception, Logger& logger) {
auto outcome = error_outcome::retry;

try {
Expand Down Expand Up @@ -113,6 +115,11 @@ error_outcome handle_client_transport_error(
return outcome;
}

template error_outcome
handle_client_transport_error<ss::logger>(std::exception_ptr, ss::logger&);
template error_outcome handle_client_transport_error<retry_chain_logger>(
std::exception_ptr, retry_chain_logger&);

ss::future<iobuf>
drain_response_stream(http::client::response_stream_ref resp) {
const auto transfer_encoding = resp->get_headers().find(
Expand Down
3 changes: 2 additions & 1 deletion src/v/cloud_storage_clients/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ namespace cloud_storage_clients::util {
/// cloud provider (e.g. connection error).
/// \param current_exception is the current exception thrown by the client
/// \param logger is the logger to use
template<typename Logger>
error_outcome handle_client_transport_error(
std::exception_ptr current_exception, ss::logger& logger);
std::exception_ptr current_exception, Logger& logger);

/// \brief: Drain the reponse stream pointed to by the 'resp' handle into an
/// iobuf
Expand Down

0 comments on commit f388831

Please sign in to comment.