From 7c59f60f47affa783317d09d36215e02b0cedc1d Mon Sep 17 00:00:00 2001 From: Peter Chang Date: Tue, 6 Feb 2024 17:17:40 -0500 Subject: [PATCH] fixing clang tidy issues --- include/factory_resolver.h | 2 +- rlclientlib/azure_factories.cc | 21 +++++++++---------- rlclientlib/azure_factories.h | 2 +- rlclientlib/factory_resolver.cc | 2 +- .../restapi_data_transport_oauth.cc | 6 +++--- .../model_mgmt/restapi_data_transport_oauth.h | 4 ++-- rlclientlib/utility/api_header_token.h | 2 +- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/include/factory_resolver.h b/include/factory_resolver.h index a43441dcf..a4cae3316 100644 --- a/include/factory_resolver.h +++ b/include/factory_resolver.h @@ -79,6 +79,6 @@ static factory_initializer _init; /** * @brief Register default factories with an authentication callback */ -void register_default_factories_callback(oauth_callback_t callback); +void register_default_factories_callback(oauth_callback_t& callback); } // namespace reinforcement_learning diff --git a/rlclientlib/azure_factories.cc b/rlclientlib/azure_factories.cc index 64c34628f..86a981b09 100644 --- a/rlclientlib/azure_factories.cc +++ b/rlclientlib/azure_factories.cc @@ -37,13 +37,13 @@ int observation_api_sender_create(std::unique_ptr& retval, const u::co int interaction_api_sender_create(std::unique_ptr& retval, const u::configuration& cfg, error_callback_fn* error_cb, i_trace* trace_logger, api_status* status); -int oauth_restapi_data_transport_create(oauth_callback_t callback, std::unique_ptr& retval, +int oauth_restapi_data_transport_create(oauth_callback_t& callback, std::unique_ptr& retval, const u::configuration& config, i_trace* trace_logger, api_status* status); -int episode_api_sender_oauth_create(oauth_callback_t callback, std::unique_ptr& retval, +int episode_api_sender_oauth_create(oauth_callback_t& callback, std::unique_ptr& retval, const u::configuration& cfg, error_callback_fn* error_cb, i_trace* trace_logger, api_status* status); -int observation_api_sender_oauth_create(oauth_callback_t callback, std::unique_ptr& retval, +int observation_api_sender_oauth_create(oauth_callback_t& callback, std::unique_ptr& retval, const u::configuration& cfg, error_callback_fn* error_cb, i_trace* trace_logger, api_status* status); -int interaction_api_sender_oauth_create(oauth_callback_t callback, std::unique_ptr& retval, +int interaction_api_sender_oauth_create(oauth_callback_t& callback, std::unique_ptr& retval, const u::configuration& cfg, error_callback_fn* error_cb, i_trace* trace_logger, api_status* status); void register_azure_factories() @@ -63,7 +63,7 @@ void register_azure_factories() sender_factory.register_type(value::EPISODE_HTTP_API_SENDER, episode_api_sender_create); } -void register_azure_oauth_factories(oauth_callback_t callback) +void register_azure_oauth_factories(oauth_callback_t& callback) { // TODO: bind functions? using namespace std::placeholders; @@ -133,7 +133,7 @@ int create_apim_http_api_sender(std::unique_ptr& retval, const u::conf return error_code::success; } -int create_apim_http_api_oauth_sender(oauth_callback_t callback, std::unique_ptr& retval, +int create_apim_http_api_oauth_sender(oauth_callback_t& callback, std::unique_ptr& retval, const u::configuration& cfg, const char* api_host, int tasks_limit, int max_http_retries, std::chrono::milliseconds max_http_retry_duration, error_callback_fn* error_cb, i_trace* trace_logger, api_status* status) @@ -211,20 +211,19 @@ int interaction_sender_create(std::unique_ptr& retval, const u::config return error_code::success; } -int oauth_restapi_data_transport_create(oauth_callback_t callback, std::unique_ptr& retval, +int oauth_restapi_data_transport_create(oauth_callback_t& callback, std::unique_ptr& retval, const u::configuration& config, i_trace* trace_logger, api_status* status) { const auto* model_uri = config.get(name::MODEL_BLOB_URI, nullptr); if (model_uri == nullptr) { RETURN_ERROR(trace_logger, status, http_model_uri_not_provided); } i_http_client* client = nullptr; RETURN_IF_FAIL(create_http_client(model_uri, config, &client, status)); - // TODO: is the scope here correct? retval.reset(new m::restapi_data_transport_oauth(std::unique_ptr(client), config, m::model_source::HTTP_API, trace_logger, callback, "https://storage.azure.com//.default")); return error_code::success; } -int episode_api_sender_oauth_create(oauth_callback_t callback, std::unique_ptr& retval, +int episode_api_sender_oauth_create(oauth_callback_t& callback, std::unique_ptr& retval, const u::configuration& cfg, error_callback_fn* error_cb, i_trace* trace_logger, api_status* status) { const auto* const api_host = cfg.get(name::EPISODE_HTTP_API_HOST, "localhost:8080"); @@ -234,7 +233,7 @@ int episode_api_sender_oauth_create(oauth_callback_t callback, std::unique_ptr& retval, +int observation_api_sender_oauth_create(oauth_callback_t& callback, std::unique_ptr& retval, const u::configuration& cfg, error_callback_fn* error_cb, i_trace* trace_logger, api_status* status) { const auto* const api_host = cfg.get(name::OBSERVATION_HTTP_API_HOST, "localhost:8080"); @@ -244,7 +243,7 @@ int observation_api_sender_oauth_create(oauth_callback_t callback, std::unique_p trace_logger, status); } -int interaction_api_sender_oauth_create(oauth_callback_t callback, std::unique_ptr& retval, +int interaction_api_sender_oauth_create(oauth_callback_t& callback, std::unique_ptr& retval, const u::configuration& cfg, error_callback_fn* error_cb, i_trace* trace_logger, api_status* status) { const auto* const api_host = cfg.get(name::INTERACTION_HTTP_API_HOST, "localhost:8080"); diff --git a/rlclientlib/azure_factories.h b/rlclientlib/azure_factories.h index fdd7f465e..b8d61f5a8 100644 --- a/rlclientlib/azure_factories.h +++ b/rlclientlib/azure_factories.h @@ -6,5 +6,5 @@ namespace reinforcement_learning { void register_azure_factories(); -void register_azure_oauth_factories(oauth_callback_t callback); +void register_azure_oauth_factories(oauth_callback_t& callback); } diff --git a/rlclientlib/factory_resolver.cc b/rlclientlib/factory_resolver.cc index debe207ff..e66d45013 100644 --- a/rlclientlib/factory_resolver.cc +++ b/rlclientlib/factory_resolver.cc @@ -72,7 +72,7 @@ factory_initializer::~factory_initializer() } } -void register_default_factories_callback(oauth_callback_t callback) +void register_default_factories_callback(oauth_callback_t& callback) { #ifdef USE_AZURE_FACTORIES register_azure_oauth_factories(callback); diff --git a/rlclientlib/model_mgmt/restapi_data_transport_oauth.cc b/rlclientlib/model_mgmt/restapi_data_transport_oauth.cc index 6f43d26e0..ad076f34f 100644 --- a/rlclientlib/model_mgmt/restapi_data_transport_oauth.cc +++ b/rlclientlib/model_mgmt/restapi_data_transport_oauth.cc @@ -23,12 +23,12 @@ namespace reinforcement_learning namespace model_management { restapi_data_transport_oauth::restapi_data_transport_oauth( - i_http_client* httpcli, i_trace* trace, oauth_callback_t callback, std::string scope) - : _httpcli(httpcli), _datasz{0}, _trace{trace}, _headerimpl(callback, scope) + i_http_client* httpcli, i_trace* trace, oauth_callback_t& callback, std::string scope) + : _httpcli(httpcli), _datasz{0}, _trace{trace}, _headerimpl(callback, std::move(scope)) { } restapi_data_transport_oauth::restapi_data_transport_oauth(std::unique_ptr&& httpcli, - utility::configuration cfg, model_source model_source, i_trace* trace, oauth_callback_t callback, std::string scope) + utility::configuration cfg, model_source model_source, i_trace* trace, oauth_callback_t& callback, std::string scope) : _httpcli(std::move(httpcli)) , _cfg(std::move(cfg)) , _model_source(model_source) diff --git a/rlclientlib/model_mgmt/restapi_data_transport_oauth.h b/rlclientlib/model_mgmt/restapi_data_transport_oauth.h index a60ce48a0..f4afa76a7 100644 --- a/rlclientlib/model_mgmt/restapi_data_transport_oauth.h +++ b/rlclientlib/model_mgmt/restapi_data_transport_oauth.h @@ -21,9 +21,9 @@ class restapi_data_transport_oauth : public i_data_transport { public: // Takes the ownership of the i_http_client and delete it at the end of lifetime - restapi_data_transport_oauth(i_http_client* httpcli, i_trace* trace, oauth_callback_t callback, std::string scope); + restapi_data_transport_oauth(i_http_client* httpcli, i_trace* trace, oauth_callback_t& callback, std::string scope); restapi_data_transport_oauth(std::unique_ptr&& httpcli, utility::configuration cfg, - model_source model_source, i_trace* trace, oauth_callback_t callback, std::string scope); + model_source model_source, i_trace* trace, oauth_callback_t& callback, std::string scope); int get_data(model_data& ret, api_status* status) override; diff --git a/rlclientlib/utility/api_header_token.h b/rlclientlib/utility/api_header_token.h index bad9b60e7..82ff74491 100644 --- a/rlclientlib/utility/api_header_token.h +++ b/rlclientlib/utility/api_header_token.h @@ -53,7 +53,7 @@ template class api_header_token_callback { public: - api_header_token_callback(oauth_callback_t token_cb, std::string scope) + api_header_token_callback(oauth_callback_t& token_cb, std::string scope) : _token_callback(token_cb), _scopes{std::move(scope)} { }