Skip to content

Commit e4d9979

Browse files
authored
VER: Release 0.47.0
2 parents e1dd418 + 69aaa4c commit e4d9979

31 files changed

+644
-132
lines changed

CHANGELOG.md

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

3+
## 0.47.0 - 2026-02-04
4+
5+
### Enhancements
6+
- Added Zstd compression support to live clients which can be enabled with
7+
`LiveBuilder::SetCompression()`. It's disabled by default
8+
- Added `Compression()` getter to `LiveBlocking` and `LiveThreaded`
9+
- Upgraded default `httplib` version to 0.30.1
10+
11+
### Breaking changes
12+
- Added an overload to the `ReadSome` method on `IReadable` for timeout support
13+
314
## 0.46.1 - 2026-01-27
415

516
### Enhancements

CMakeLists.txt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.24..4.2)
66

77
project(
88
databento
9-
VERSION 0.46.1
9+
VERSION 0.47.0
1010
LANGUAGES CXX
1111
DESCRIPTION "Official Databento client library"
1212
)
@@ -128,10 +128,6 @@ endif()
128128

129129
find_package(OpenSSL REQUIRED)
130130
find_package(zstd REQUIRED)
131-
if (APPLE)
132-
find_library(CORE_FOUNDATION_LIB CoreFoundation REQUIRED)
133-
find_library(CFNETWORK_LIB CFNetwork REQUIRED)
134-
endif()
135131
if(NOT TARGET zstd::libzstd)
136132
if(TARGET zstd::libzstd_shared)
137133
add_library(zstd::libzstd ALIAS zstd::libzstd_shared)
@@ -182,7 +178,7 @@ if(${PROJECT_NAME_UPPERCASE}_USE_EXTERNAL_HTTPLIB)
182178
find_package(httplib REQUIRED)
183179
endif()
184180
else()
185-
set(httplib_version 0.28.0)
181+
set(httplib_version 0.30.1)
186182
FetchContent_Declare(
187183
httplib
188184
URL https://github.com/yhirose/cpp-httplib/archive/refs/tags/v${httplib_version}.tar.gz
@@ -227,9 +223,6 @@ target_link_libraries(
227223
OpenSSL::SSL
228224
Threads::Threads
229225
zstd::libzstd
230-
# macOS-specific libraries required by httplib
231-
$<$<PLATFORM_ID:Darwin>:${CFNETWORK_LIB}>
232-
$<$<PLATFORM_ID:Darwin>:${CORE_FRAMEWORK_LIB}>
233226
)
234227

235228
target_compile_definitions(

cmake/SourcesAndHeaders.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ set(sources
5454
src/detail/dbn_buffer_decoder.cpp
5555
src/detail/http_client.cpp
5656
src/detail/json_helpers.cpp
57+
src/detail/live_connection.cpp
5758
src/detail/scoped_fd.cpp
5859
src/detail/sha256_hasher.cpp
5960
src/detail/tcp_client.cpp
61+
src/detail/tcp_readable.cpp
6062
src/detail/zstd_stream.cpp
6163
src/enums.cpp
6264
src/exceptions.cpp

examples/live/simple.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ int main() {
2525
.SetSendTsOut(true)
2626
.SetKeyFromEnv()
2727
.SetDataset(db::Dataset::GlbxMdp3)
28+
.SetCompression(db::Compression::Zstd)
2829
.BuildThreaded();
2930

3031
// Set up signal handler for Ctrl+C
3132
std::signal(SIGINT, [](int signal) { gSignal = signal; });
3233

33-
std::vector<std::string> symbols{"ESZ5", "ESZ5 C6200", "ESZ5 P5500"};
34+
std::vector<std::string> symbols{"ESZ6", "ESZ6 C8200", "ESZ6 P7500"};
3435
client.Subscribe(symbols, db::Schema::Definition, db::SType::RawSymbol);
3536
client.Subscribe(symbols, db::Schema::Mbo, db::SType::RawSymbol);
3637

include/databento/detail/buffer.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class Buffer : public IReadable, public IWritable {
3838
// Will throw if `length > ReadCapacity()`.
3939
void ReadExact(std::byte* buffer, std::size_t length) override;
4040
std::size_t ReadSome(std::byte* buffer, std::size_t max_length) override;
41+
// timeout is ignored
42+
IReadable::Result ReadSome(std::byte* buffer, std::size_t max_length,
43+
std::chrono::milliseconds timeout) override;
4144

4245
std::byte* ReadBegin() { return read_pos_; }
4346
std::byte* ReadEnd() { return write_pos_; }
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#pragma once
2+
3+
#include <chrono>
4+
#include <cstddef>
5+
#include <cstdint>
6+
#include <optional>
7+
#include <string>
8+
#include <string_view>
9+
10+
#include "databento/detail/tcp_client.hpp"
11+
#include "databento/detail/zstd_stream.hpp"
12+
#include "databento/enums.hpp"
13+
#include "databento/ireadable.hpp"
14+
#include "databento/iwritable.hpp"
15+
16+
namespace databento::detail {
17+
// Manages the TCP connection to the live gateway with optionally compressed reads for
18+
// the DBN data.
19+
class LiveConnection : IWritable {
20+
public:
21+
LiveConnection(const std::string& gateway, std::uint16_t port);
22+
23+
void WriteAll(std::string_view str);
24+
void WriteAll(const std::byte* buffer, std::size_t size);
25+
void ReadExact(std::byte* buffer, std::size_t size);
26+
IReadable::Result ReadSome(std::byte* buffer, std::size_t max_size);
27+
IReadable::Result ReadSome(std::byte* buffer, std::size_t max_size,
28+
std::chrono::milliseconds timeout);
29+
// Closes the socket.
30+
void Close();
31+
// Sets compression for subsequent reads.
32+
void SetCompression(Compression compression);
33+
34+
private:
35+
TcpClient client_;
36+
std::optional<ZstdDecodeStream> zstd_stream_;
37+
};
38+
} // namespace databento::detail

include/databento/detail/tcp_client.hpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,11 @@
77
#include <string_view>
88

99
#include "databento/detail/scoped_fd.hpp" // ScopedFd
10+
#include "databento/ireadable.hpp"
1011

1112
namespace databento::detail {
1213
class TcpClient {
1314
public:
14-
enum class Status : std::uint8_t {
15-
Ok,
16-
Timeout,
17-
Closed,
18-
};
19-
20-
struct Result {
21-
std::size_t read_size;
22-
Status status;
23-
};
24-
2515
struct RetryConf {
2616
std::uint32_t max_attempts{1};
2717
std::chrono::seconds max_wait{std::chrono::minutes{1}};
@@ -33,11 +23,11 @@ class TcpClient {
3323
void WriteAll(std::string_view str);
3424
void WriteAll(const std::byte* buffer, std::size_t size);
3525
void ReadExact(std::byte* buffer, std::size_t size);
36-
Result ReadSome(std::byte* buffer, std::size_t max_size);
26+
IReadable::Result ReadSome(std::byte* buffer, std::size_t max_size);
3727
// Passing a timeout of 0 will block until data is available of the socket is
3828
// closed, the same behavior as the Read overload without a timeout.
39-
Result ReadSome(std::byte* buffer, std::size_t max_size,
40-
std::chrono::milliseconds timeout);
29+
IReadable::Result ReadSome(std::byte* buffer, std::size_t max_size,
30+
std::chrono::milliseconds timeout);
4131
// Closes the socket.
4232
void Close();
4333

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#include <chrono>
4+
#include <cstddef>
5+
6+
#include "databento/detail/tcp_client.hpp"
7+
#include "databento/ireadable.hpp"
8+
9+
namespace databento::detail {
10+
// Adapter wrapping TcpClient to implement IReadable interface and be passed
11+
// as a non-owned pointer to ZstdDecodeStream.
12+
class TcpReadable : public IReadable {
13+
public:
14+
explicit TcpReadable(TcpClient* client) : client_{client} {}
15+
16+
void ReadExact(std::byte* buffer, std::size_t length) override;
17+
std::size_t ReadSome(std::byte* buffer, std::size_t max_length) override;
18+
IReadable::Result ReadSome(std::byte* buffer, std::size_t max_length,
19+
std::chrono::milliseconds timeout) override;
20+
21+
private:
22+
TcpClient* client_;
23+
};
24+
} // namespace databento::detail

include/databento/detail/zstd_stream.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <zstd.h>
44

5+
#include <chrono>
56
#include <cstddef> // size_t
67
#include <memory> // unique_ptr
78
#include <vector>
@@ -19,9 +20,12 @@ class ZstdDecodeStream : public IReadable {
1920

2021
// Read exactly `length` bytes into `buffer`.
2122
void ReadExact(std::byte* buffer, std::size_t length) override;
22-
// Read at most `length` bytes. Returns the number of bytes read. Will only
23+
// Read at most `max_length` bytes. Returns the number of bytes read. Will only
2324
// return 0 if the end of the stream is reached.
2425
std::size_t ReadSome(std::byte* buffer, std::size_t max_length) override;
26+
// Read at most `max_length` bytes with timeout support.
27+
IReadable::Result ReadSome(std::byte* buffer, std::size_t max_length,
28+
std::chrono::milliseconds timeout) override;
2529

2630
IReadable* Input() const { return input_.get(); }
2731

@@ -44,6 +48,8 @@ class ZstdCompressStream : public IWritable {
4448
~ZstdCompressStream() override;
4549

4650
void WriteAll(const std::byte* buffer, std::size_t length) override;
51+
// Flush any buffered data without ending the stream
52+
void Flush();
4753

4854
private:
4955
ILogReceiver* log_receiver_;

include/databento/file_stream.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class InFileStream : public IReadable {
1717
// Read at most `length` bytes. Returns the number of bytes read. Will only
1818
// return 0 if the end of the stream is reached.
1919
std::size_t ReadSome(std::byte* buffer, std::size_t max_length) override;
20+
// timeout is ignored
21+
Result ReadSome(std::byte* buffer, std::size_t max_length,
22+
std::chrono::milliseconds timeout) override;
2023

2124
private:
2225
std::ifstream stream_;

0 commit comments

Comments
 (0)