|
13 | 13 | #include <iterator> // back_inserter |
14 | 14 | #include <optional> |
15 | 15 | #include <sstream> |
| 16 | +#include <string_view> |
16 | 17 | #include <system_error> |
17 | 18 | #include <utility> // move |
18 | 19 | #include <variant> |
@@ -226,7 +227,7 @@ Historical::Historical(ILogReceiver* log_receiver, std::string key, std::string |
226 | 227 | upgrade_policy_{upgrade_policy}, |
227 | 228 | client_{log_receiver, key_, gateway_, port} {} |
228 | 229 |
|
229 | | -static const std::string kBatchSubmitJobEndpoint = "Historical::BatchSubmitJob"; |
| 230 | +constexpr std::string_view kBatchSubmitJobEndpoint = "Historical::BatchSubmitJob"; |
230 | 231 |
|
231 | 232 | databento::BatchJob Historical::BatchSubmitJob( |
232 | 233 | const std::string& dataset, const std::vector<std::string>& symbols, Schema schema, |
@@ -471,7 +472,7 @@ void Historical::DownloadFile(const std::string& url, |
471 | 472 | } catch (const databento::Exception& exc) { |
472 | 473 | retry += 1; |
473 | 474 | if (retry == kMaxRetries) { |
474 | | - throw exc; |
| 475 | + throw; |
475 | 476 | } |
476 | 477 | ss.str(""); |
477 | 478 | ss << '[' << kMethod << "] Retrying download attempt " << retry + 1 << " after " |
@@ -685,7 +686,7 @@ databento::DatasetRange Historical::MetadataGetDatasetRange( |
685 | 686 | std::move(range_by_schema)}; |
686 | 687 | } |
687 | 688 |
|
688 | | -static const std::string kMetadataGetRecordCountEndpoint = |
| 689 | +constexpr std::string_view kMetadataGetRecordCountEndpoint = |
689 | 690 | "Historical::MetadataGetRecordCount"; |
690 | 691 |
|
691 | 692 | std::uint64_t Historical::MetadataGetRecordCount( |
@@ -738,7 +739,7 @@ std::uint64_t Historical::MetadataGetRecordCount(const httplib::Params& params) |
738 | 739 | return json; |
739 | 740 | } |
740 | 741 |
|
741 | | -static const std::string kMetadataGetBillableSizeEndpoint = |
| 742 | +constexpr std::string_view kMetadataGetBillableSizeEndpoint = |
742 | 743 | "Historical::MetadataGetBillableSize"; |
743 | 744 |
|
744 | 745 | std::uint64_t Historical::MetadataGetBillableSize( |
@@ -792,7 +793,7 @@ std::uint64_t Historical::MetadataGetBillableSize(const httplib::Params& params) |
792 | 793 | return json; |
793 | 794 | } |
794 | 795 |
|
795 | | -static const std::string kMetadataGetCostEndpoint = "Historical::MetadataGetCost"; |
| 796 | +constexpr std::string_view kMetadataGetCostEndpoint = "Historical::MetadataGetCost"; |
796 | 797 |
|
797 | 798 | double Historical::MetadataGetCost(const std::string& dataset, |
798 | 799 | const DateTimeRange<UnixNanos>& datetime_range, |
@@ -912,8 +913,13 @@ databento::SymbologyResolution Historical::SymbologyResolve( |
912 | 913 | return res; |
913 | 914 | } |
914 | 915 |
|
915 | | -static const std::string kTimeseriesGetRangeEndpoint = "Historical::TimeseriesGetRange"; |
916 | | -static const std::string kTimeseriesGetRangePath = ::BuildTimeseriesPath(".get_range"); |
| 916 | +constexpr std::string_view kTimeseriesGetRangeEndpoint = |
| 917 | + "Historical::TimeseriesGetRange"; |
| 918 | + |
| 919 | +static const std::string& TimeseriesGetRangePath() { |
| 920 | + static const std::string kPath = ::BuildTimeseriesPath(".get_range"); |
| 921 | + return kPath; |
| 922 | +} |
917 | 923 |
|
918 | 924 | void Historical::TimeseriesGetRange(const std::string& dataset, |
919 | 925 | const DateTimeRange<UnixNanos>& datetime_range, |
@@ -986,7 +992,7 @@ void Historical::TimeseriesGetRange(const HttplibParams& params, |
986 | 992 |
|
987 | 993 | bool early_exit = false; |
988 | 994 | this->client_.PostRawStream( |
989 | | - kTimeseriesGetRangePath, params, |
| 995 | + TimeseriesGetRangePath(), params, |
990 | 996 | [&decoder, &early_exit](const char* data, std::size_t length) mutable { |
991 | 997 | if (decoder.Process(data, length) == KeepGoing::Continue) { |
992 | 998 | return true; |
@@ -1050,11 +1056,11 @@ databento::DbnStore Historical::TimeseriesGetRange( |
1050 | 1056 | return this->TimeseriesGetRange(params); |
1051 | 1057 | } |
1052 | 1058 | databento::DbnStore Historical::TimeseriesGetRange(const HttplibParams& params) { |
1053 | | - auto stream = client_.OpenPostStream(kTimeseriesGetRangePath, params); |
| 1059 | + auto stream = client_.OpenPostStream(TimeseriesGetRangePath(), params); |
1054 | 1060 | return DbnStore{log_receiver_, std::move(stream), upgrade_policy_}; |
1055 | 1061 | } |
1056 | 1062 |
|
1057 | | -static const std::string kTimeseriesGetRangeToFileEndpoint = |
| 1063 | +constexpr std::string_view kTimeseriesGetRangeToFileEndpoint = |
1058 | 1064 | "Historical::TimeseriesGetRangeToFile"; |
1059 | 1065 |
|
1060 | 1066 | databento::DbnStore Historical::TimeseriesGetRangeToFile( |
@@ -1111,7 +1117,7 @@ databento::DbnStore Historical::TimeseriesGetRangeToFile( |
1111 | 1117 | const HttplibParams& params, const std::filesystem::path& file_path) { |
1112 | 1118 | { |
1113 | 1119 | OutFileStream out_file{file_path}; |
1114 | | - this->client_.PostRawStream(kTimeseriesGetRangePath, params, |
| 1120 | + this->client_.PostRawStream(TimeseriesGetRangePath(), params, |
1115 | 1121 | [&out_file](const char* data, std::size_t length) { |
1116 | 1122 | out_file.WriteAll( |
1117 | 1123 | reinterpret_cast<const std::byte*>(data), length); |
|
0 commit comments