Skip to content

Commit

Permalink
fixing clang tidy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
peterychang committed Feb 6, 2024
1 parent 5b5de4d commit 7c59f60
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion include/factory_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 10 additions & 11 deletions rlclientlib/azure_factories.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ int observation_api_sender_create(std::unique_ptr<i_sender>& retval, const u::co
int interaction_api_sender_create(std::unique_ptr<i_sender>& 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<m::i_data_transport>& retval,
int oauth_restapi_data_transport_create(oauth_callback_t& callback, std::unique_ptr<m::i_data_transport>& 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<i_sender>& retval,
int episode_api_sender_oauth_create(oauth_callback_t& callback, std::unique_ptr<i_sender>& 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<i_sender>& retval,
int observation_api_sender_oauth_create(oauth_callback_t& callback, std::unique_ptr<i_sender>& 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<i_sender>& retval,
int interaction_api_sender_oauth_create(oauth_callback_t& callback, std::unique_ptr<i_sender>& retval,
const u::configuration& cfg, error_callback_fn* error_cb, i_trace* trace_logger, api_status* status);

void register_azure_factories()
Expand All @@ -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;
Expand Down Expand Up @@ -133,7 +133,7 @@ int create_apim_http_api_sender(std::unique_ptr<i_sender>& retval, const u::conf
return error_code::success;
}

int create_apim_http_api_oauth_sender(oauth_callback_t callback, std::unique_ptr<i_sender>& retval,
int create_apim_http_api_oauth_sender(oauth_callback_t& callback, std::unique_ptr<i_sender>& 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)
Expand Down Expand Up @@ -211,20 +211,19 @@ int interaction_sender_create(std::unique_ptr<i_sender>& retval, const u::config
return error_code::success;
}

int oauth_restapi_data_transport_create(oauth_callback_t callback, std::unique_ptr<m::i_data_transport>& retval,
int oauth_restapi_data_transport_create(oauth_callback_t& callback, std::unique_ptr<m::i_data_transport>& 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<i_http_client>(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<i_sender>& retval,
int episode_api_sender_oauth_create(oauth_callback_t& callback, std::unique_ptr<i_sender>& 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");
Expand All @@ -234,7 +233,7 @@ int episode_api_sender_oauth_create(oauth_callback_t callback, std::unique_ptr<i
trace_logger, status);
}

int observation_api_sender_oauth_create(oauth_callback_t callback, std::unique_ptr<i_sender>& retval,
int observation_api_sender_oauth_create(oauth_callback_t& callback, std::unique_ptr<i_sender>& 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");
Expand All @@ -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<i_sender>& retval,
int interaction_api_sender_oauth_create(oauth_callback_t& callback, std::unique_ptr<i_sender>& 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");
Expand Down
2 changes: 1 addition & 1 deletion rlclientlib/azure_factories.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion rlclientlib/factory_resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions rlclientlib/model_mgmt/restapi_data_transport_oauth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<i_http_client>&& 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)
Expand Down
4 changes: 2 additions & 2 deletions rlclientlib/model_mgmt/restapi_data_transport_oauth.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<i_http_client>&& 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;

Expand Down
2 changes: 1 addition & 1 deletion rlclientlib/utility/api_header_token.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ template <typename Resource>
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)}
{
}
Expand Down

0 comments on commit 7c59f60

Please sign in to comment.