refactor
Some checks failed
BlockStorage/repertory_osx_builds/pipeline/head There was a failure building this commit
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good

This commit is contained in:
2023-11-18 22:47:07 -06:00
parent 5ac2a24611
commit eec3653c6b
28 changed files with 267 additions and 241 deletions

View File

@@ -43,36 +43,33 @@ inline void create_comm(std::unique_ptr<intf_t> &comm, const config_t &config) {
} // namespace
namespace repertory {
auto create_provider(const provider_type &pt, app_config &config)
auto create_provider(const provider_type &prov, app_config &config)
-> std::unique_ptr<i_provider> {
static std::mutex mutex;
mutex_lock lock(mutex);
static std::unique_ptr<i_http_comm> comm;
switch (pt) {
switch (prov) {
case provider_type::sia: {
create_comm<i_http_comm, curl_comm, host_config>(comm,
config.get_host_config());
return std::unique_ptr<i_provider>(
dynamic_cast<i_provider *>(new sia_provider(config, *comm)));
return std::make_unique<sia_provider>(config, *comm);
}
#if defined(REPERTORY_ENABLE_S3)
case provider_type::s3: {
create_comm<i_http_comm, curl_comm, s3_config>(comm,
config.get_s3_config());
return std::unique_ptr<i_provider>(
dynamic_cast<i_provider *>(new s3_provider(config, *comm)));
return std::make_unique<s3_provider>(config, *comm);
}
#endif // defined(REPERTORY_ENABLE_S3)
case provider_type::encrypt: {
return std::unique_ptr<i_provider>(
dynamic_cast<i_provider *>(new encrypt_provider(config)));
return std::make_unique<encrypt_provider>(config);
}
case provider_type::unknown:
default:
throw startup_exception("provider not supported: " +
app_config::get_provider_display_name(pt));
app_config::get_provider_display_name(prov));
}
}
} // namespace repertory