Skip to content

Commit 5a1b7ad

Browse files
authored
VER: Release 0.9.0
2 parents 97fa0dd + 1a66299 commit 5a1b7ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1087
-441
lines changed

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ jobs:
3232
- name: Set output
3333
id: vars
3434
run: |
35-
echo "::set-output name=tag_name::v$(scripts/get_version.sh)"
36-
echo "::set-output name=release_name::$(scripts/get_version.sh)"
35+
echo "name=tag_name::v$(scripts/get_version.sh)" >> $GITHUB_OUTPUT
36+
echo "name=release_name::$(scripts/get_version.sh)" >> $GITHUB_OUTPUT
3737
3838
# Create GitHub release
3939
- name: Create release

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 0.9.0 - 2023-06-13
4+
- Added `Reconnect` methods to `LiveBlocking` and `LiveThreaded`
5+
- Added optional `exception_callback` argument to `LiveThreaded::Start` to improve
6+
error handling options
7+
- Added batch download support data files (`condition.json` and `symbology.json`)
8+
- Added support for logging warnings from Historical API
9+
- Changed `use_ts_out` default to `false`
10+
- Fixed missing definition for `operator==` for `ImbalanceMsg`
11+
- Removed 10 minute minimum request time range restriction
12+
313
## 0.8.0 - 2023-05-16
414
- Changed `end` and `end_date` to optional to support new forward-fill behaviour
515
- Renamed `booklevel` MBP field to `levels` for brevity and consistent naming

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.14)
44
# Project details
55
#
66

7-
project("databento" VERSION 0.8.0 LANGUAGES CXX)
7+
project("databento" VERSION 0.9.0 LANGUAGES CXX)
88
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE)
99

1010
#

cmake/SourcesAndHeaders.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ set(headers
2222
include/databento/with_ts_out.hpp
2323
include/databento/detail/file_stream.hpp
2424
include/databento/detail/http_client.hpp
25+
include/databento/detail/json_helpers.hpp
2526
include/databento/detail/scoped_fd.hpp
2627
include/databento/detail/scoped_thread.hpp
2728
include/databento/detail/shared_channel.hpp
@@ -49,6 +50,7 @@ set(sources
4950
src/symbology.cpp
5051
src/detail/file_stream.cpp
5152
src/detail/http_client.cpp
53+
src/detail/json_helpers.cpp
5254
src/detail/scoped_fd.cpp
5355
src/detail/shared_channel.cpp
5456
src/detail/tcp_client.cpp

cmake/StandardSettings.cmake

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@ option(${PROJECT_NAME_UPPERCASE}_USE_EXTERNAL_GTEST "Use an external google test
1111
#
1212

1313
option(${PROJECT_NAME_UPPERCASE}_WARNINGS_AS_ERRORS "Treat compiler warnings as errors." ${IS_MAIN_PROJECT})
14-
option(${PROJECT_NAME_UPPERCASE}_FORCE_COLOR_OUTPUT "Always produce ANSI-colored output" OFF)
15-
16-
if(${PROJECT_NAME_UPPERCASE}_FORCE_COLOR_OUTPUT)
17-
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
18-
add_compile_options(-fdiagnostics-color=always)
19-
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
20-
add_compile_options(-fcolor-diagnostics)
21-
else()
22-
message(WARNING "Couldn't force color output with unsupported compiler: ${CMAKE_CXX_COMPILER_ID}")
23-
endif()
24-
endif()
2514

2615
#
2716
# Unit testing

include/databento/detail/http_client.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
#include <string>
1313

1414
namespace databento {
15+
class ILogReceiver;
1516
namespace detail {
1617
class HttpClient {
1718
public:
18-
HttpClient(const std::string& key, const std::string& gateway);
19-
HttpClient(const std::string& key, const std::string& gateway,
20-
std::uint16_t port);
19+
HttpClient(ILogReceiver* log_receiver, const std::string& key,
20+
const std::string& gateway);
21+
HttpClient(ILogReceiver* log_receiver, const std::string& key,
22+
const std::string& gateway, std::uint16_t port);
2123

2224
nlohmann::json GetJson(const std::string& path,
2325
const httplib::Params& params);
@@ -27,12 +29,14 @@ class HttpClient {
2729
const httplib::ContentReceiver& callback);
2830

2931
private:
30-
static nlohmann::json CheckAndParseResponse(const std::string& path,
31-
httplib::Result&& res);
32+
nlohmann::json CheckAndParseResponse(const std::string& path,
33+
httplib::Result&& res) const;
34+
void CheckWarnings(const httplib::Response& response) const;
3235
static bool IsErrorStatus(int status_code);
3336

3437
static const httplib::Headers kHeaders;
3538

39+
ILogReceiver* log_receiver_;
3640
httplib::Client client_;
3741
};
3842
} // namespace detail
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#pragma once
2+
3+
#include <nlohmann/json.hpp>
4+
5+
#include <map> // multimap
6+
#include <string>
7+
#include <vector>
8+
9+
#include "databento/datetime.hpp" // UnixNanos
10+
#include "databento/enums.hpp" // FromString
11+
#include "databento/exceptions.hpp" // JsonResponseError
12+
13+
namespace httplib {
14+
using Params = std::multimap<std::string, std::string>;
15+
}
16+
17+
namespace databento {
18+
namespace detail {
19+
void SetIfNotEmpty(httplib::Params* params, const std::string& key,
20+
const std::string& value);
21+
void SetIfNotEmpty(httplib::Params* params, const std::string& key,
22+
const std::vector<databento::JobState>& states);
23+
24+
template <typename T>
25+
void SetIfPositive(httplib::Params* params, const std::string& key,
26+
const T value) {
27+
if (value > 0) {
28+
params->emplace(key, std::to_string(value));
29+
}
30+
}
31+
32+
template <>
33+
inline void SetIfPositive<databento::UnixNanos>(
34+
httplib::Params* params, const std::string& key,
35+
const databento::UnixNanos value) {
36+
if (value.time_since_epoch().count()) {
37+
params->emplace(key, databento::ToString(value));
38+
}
39+
}
40+
41+
const nlohmann::json& CheckedAt(const std::string& endpoint,
42+
const nlohmann::json& json,
43+
const std::string& key);
44+
45+
template <typename T>
46+
T FromCheckedAtString(const std::string& endpoint, const nlohmann::json& json,
47+
const std::string& key) {
48+
const auto& val_json = CheckedAt(endpoint, json, key);
49+
if (!val_json.is_string()) {
50+
throw JsonResponseError::TypeMismatch(endpoint, key + " string", val_json);
51+
}
52+
return databento::FromString<T>(val_json);
53+
}
54+
55+
template <typename T>
56+
T FromCheckedAtStringOrNull(const std::string& endpoint,
57+
const nlohmann::json& json, const std::string& key,
58+
T null_value) {
59+
const auto& val_json = CheckedAt(endpoint, json, key);
60+
if (val_json.is_null()) {
61+
return null_value;
62+
}
63+
if (val_json.is_string()) {
64+
return databento::FromString<T>(val_json);
65+
}
66+
throw JsonResponseError::TypeMismatch(endpoint, key + " null or string",
67+
val_json);
68+
}
69+
70+
template <typename T>
71+
T ParseAt(const std::string& endpoint, const nlohmann::json& json,
72+
const std::string& key);
73+
template <>
74+
bool ParseAt(const std::string& endpoint, const nlohmann::json& json,
75+
const std::string& key);
76+
template <>
77+
std::string ParseAt(const std::string& endpoint, const nlohmann::json& json,
78+
const std::string& key);
79+
template <>
80+
std::size_t ParseAt(const std::string& endpoint, const nlohmann::json& json,
81+
const std::string& key);
82+
template <>
83+
double ParseAt(const std::string& endpoint, const nlohmann::json& json,
84+
const std::string& key);
85+
template <>
86+
std::vector<std::string> ParseAt(const std::string& endpoint,
87+
const nlohmann::json& json,
88+
const std::string& key);
89+
90+
} // namespace detail
91+
} // namespace databento

include/databento/detail/scoped_thread.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class ScopedThread {
3030
}
3131
}
3232

33+
std::thread::id Id() const { return thread_.get_id(); }
3334
bool Joinable() const { return thread_.joinable(); }
3435
void Join() { return thread_.join(); }
3536

include/databento/detail/tcp_client.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ class TcpClient {
2121
Status status;
2222
};
2323

24+
struct RetryConf {
25+
std::uint32_t max_attempts{1};
26+
std::chrono::seconds max_wait{std::chrono::minutes{1}};
27+
};
28+
2429
TcpClient(const std::string& gateway, std::uint16_t port);
30+
TcpClient(const std::string& gateway, std::uint16_t port,
31+
RetryConf retry_conf);
2532

2633
void WriteAll(const std::string& str);
2734
void WriteAll(const char* buffer, std::size_t size);
@@ -35,7 +42,8 @@ class TcpClient {
3542
void Close();
3643

3744
private:
38-
static ScopedFd InitSocket(const std::string& gateway, std::uint16_t port);
45+
static ScopedFd InitSocket(const std::string& gateway, std::uint16_t port,
46+
RetryConf retry_conf);
3947

4048
ScopedFd socket_;
4149
};

include/databento/enums.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ enum class Compression : std::uint8_t {
5151
enum class SType : std::uint8_t {
5252
InstrumentId = 0,
5353
RawSymbol = 1,
54-
// Deprecated in 0.7.0. Separated into Parent and Continuous.
55-
SmartDeprecated = 2,
5654
Continuous = 3,
5755
Parent = 4,
5856
};

0 commit comments

Comments
 (0)