Skip to content

Commit 065bcb6

Browse files
authored
VER: Release 0.15.0
2 parents b519265 + 25886d6 commit 065bcb6

File tree

8 files changed

+121
-9
lines changed

8 files changed

+121
-9
lines changed

CHANGELOG.md

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

3+
## 0.15.0 - 2023-01-16
4+
5+
### Breaking changes
6+
- Increased size of `SystemMsg` and `ErrorMsg` to provide better messages from Live
7+
gateway
8+
- Increased length of `err` and `msg` fields for more detailed messages
9+
- Added `is_last` field to `ErrorMsg` to indicate the last error in a chain
10+
- Added `code` field to `SystemMsg` and `ErrorMsg`, although currently unused
11+
- Added new `is_last` parameter to `ErrorMsg::new`
12+
- Decoding these is backwards-compatible and records with longer messages won't be
13+
sent during the DBN version 2 migration period
14+
- Renamed previous records to `ErrorMsgV1` and `SystemMsgV1`
15+
316
## 0.14.1 - 2023-12-18
417

518
### Enhancements

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.14.1 LANGUAGES CXX)
7+
project("databento" VERSION 0.15.0 LANGUAGES CXX)
88
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE)
99

1010
#

example/live/simple.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int main() {
2929
// Set up signal handler for Ctrl+C
3030
std::signal(SIGINT, [](int signal) { gSignal = signal; });
3131

32-
std::vector<std::string> symbols{"ESM3", "ESM3 C4200", "ESM3 P4100"};
32+
std::vector<std::string> symbols{"ESZ4", "ESZ4 C4200", "ESZ4 P4100"};
3333
client.Subscribe(symbols, databento::Schema::Definition,
3434
databento::SType::RawSymbol);
3535
client.Subscribe(symbols, databento::Schema::Mbo,

include/databento/compat.hpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ constexpr std::size_t VersionSymbolCstrLen(std::uint8_t version) {
1818
}
1919

2020
using InstrumentDefMsgV2 = InstrumentDefMsg;
21+
using ErrorMsgV2 = ErrorMsg;
2122
using SymbolMappingMsgV2 = SymbolMappingMsg;
23+
using SystemMsgV2 = SystemMsg;
2224

2325
// DBN version 1 instrument definition.
2426
struct InstrumentDefMsgV1 {
@@ -111,6 +113,21 @@ struct InstrumentDefMsgV1 {
111113
static_assert(sizeof(InstrumentDefMsgV1) == 360, "Size must match Rust");
112114
static_assert(alignof(InstrumentDefMsgV1) == 8, "Must have 8-byte alignment");
113115

116+
// An error message from the Live Subscription Gateway (LSG). This will never
117+
// be present in historical data.
118+
struct ErrorMsgV1 {
119+
static bool HasRType(RType rtype) { return rtype == RType::Error; }
120+
121+
ErrorMsgV2 ToV2() const;
122+
UnixNanos IndexTs() const { return hd.ts_event; }
123+
const char* Err() const { return err.data(); }
124+
125+
RecordHeader hd;
126+
std::array<char, 64> err;
127+
};
128+
static_assert(sizeof(ErrorMsgV1) == 80, "ErrorMsg size must match Rust");
129+
static_assert(alignof(ErrorMsgV1) == 8, "Must have 8-byte alignment");
130+
114131
/// A symbol mapping message.
115132
struct SymbolMappingMsgV1 {
116133
static bool HasRType(RType rtype) { return rtype == RType::SymbolMapping; }
@@ -130,11 +147,33 @@ struct SymbolMappingMsgV1 {
130147
static_assert(sizeof(SymbolMappingMsgV1) == 80, "Size must match Rust");
131148
static_assert(alignof(SymbolMappingMsgV1) == 8, "Must have 8-byte alignment");
132149

150+
struct SystemMsgV1 {
151+
static bool HasRType(RType rtype) { return rtype == RType::System; }
152+
153+
SystemMsgV2 ToV2() const;
154+
UnixNanos IndexTs() const { return hd.ts_event; }
155+
const char* Msg() const { return msg.data(); }
156+
bool IsHeartbeat() const {
157+
return std::strncmp(msg.data(), "Heartbeat", 9) == 0;
158+
}
159+
160+
RecordHeader hd;
161+
std::array<char, 64> msg;
162+
};
163+
static_assert(sizeof(SystemMsgV1) == 80, "SystemMsg size must match Rust");
164+
static_assert(alignof(SystemMsgV1) == 8, "Must have 8-byte alignment");
165+
133166
bool operator==(const InstrumentDefMsgV1& lhs, const InstrumentDefMsgV1& rhs);
134167
inline bool operator!=(const InstrumentDefMsgV1& lhs,
135168
const InstrumentDefMsgV1& rhs) {
136169
return !(lhs == rhs);
137170
}
171+
inline bool operator==(const ErrorMsgV1& lhs, const ErrorMsgV1& rhs) {
172+
return std::tie(lhs.hd, lhs.err) == std::tie(rhs.hd, rhs.err);
173+
}
174+
inline bool operator!=(const ErrorMsgV1& lhs, const ErrorMsgV1& rhs) {
175+
return !(lhs == rhs);
176+
}
138177
inline bool operator==(const SymbolMappingMsgV1& lhs,
139178
const SymbolMappingMsgV1& rhs) {
140179
return std::tie(lhs.hd, lhs.stype_in_symbol, lhs.stype_out_symbol,
@@ -146,10 +185,20 @@ inline bool operator!=(const SymbolMappingMsgV1& lhs,
146185
const SymbolMappingMsgV1& rhs) {
147186
return !(lhs == rhs);
148187
}
188+
inline bool operator==(const SystemMsgV1& lhs, const SystemMsgV1& rhs) {
189+
return std::tie(lhs.hd, lhs.msg) == std::tie(rhs.hd, rhs.msg);
190+
}
191+
inline bool operator!=(const SystemMsgV1& lhs, const SystemMsgV1& rhs) {
192+
return !(lhs == rhs);
193+
}
149194
std::string ToString(const InstrumentDefMsgV1& instr_def_msg);
150195
std::ostream& operator<<(std::ostream& stream,
151196
const InstrumentDefMsgV1& instr_def_msg);
197+
std::string ToString(const ErrorMsgV1& err_msg);
198+
std::ostream& operator<<(std::ostream& stream, const ErrorMsgV1& err_msg);
152199
std::string ToString(const SymbolMappingMsgV1& symbol_mapping_msg);
153200
std::ostream& operator<<(std::ostream& stream,
154201
const SymbolMappingMsgV1& symbol_mapping_msg);
202+
std::string ToString(const SystemMsgV1& sys_msg);
203+
std::ostream& operator<<(std::ostream& stream, const SystemMsgV1& sys_msg);
155204
} // namespace databento

include/databento/record.hpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,11 @@ struct ErrorMsg {
337337
const char* Err() const { return err.data(); }
338338

339339
RecordHeader hd;
340-
std::array<char, 64> err;
340+
std::array<char, 302> err;
341+
std::uint8_t code;
342+
std::uint8_t is_last;
341343
};
342-
static_assert(sizeof(ErrorMsg) == 80, "ErrorMsg size must match Rust");
344+
static_assert(sizeof(ErrorMsg) == 320, "ErrorMsg size must match Rust");
343345
static_assert(alignof(ErrorMsg) == 8, "Must have 8-byte alignment");
344346

345347
/// A symbol mapping message.
@@ -372,9 +374,10 @@ struct SystemMsg {
372374
}
373375

374376
RecordHeader hd;
375-
std::array<char, 64> msg;
377+
std::array<char, 303> msg;
378+
std::uint8_t code;
376379
};
377-
static_assert(sizeof(SystemMsg) == 80, "SystemMsg size must match Rust");
380+
static_assert(sizeof(SystemMsg) == 320, "SystemMsg size must match Rust");
378381
static_assert(alignof(SystemMsg) == 8, "Must have 8-byte alignment");
379382

380383
inline bool operator==(const RecordHeader& lhs, const RecordHeader& rhs) {
@@ -480,14 +483,15 @@ inline bool operator!=(const StatMsg& lhs, const StatMsg& rhs) {
480483
}
481484

482485
inline bool operator==(const ErrorMsg& lhs, const ErrorMsg& rhs) {
483-
return lhs.hd == rhs.hd && lhs.err == rhs.err;
486+
return lhs.hd == rhs.hd && lhs.err == rhs.err && lhs.code == rhs.code &&
487+
lhs.is_last == rhs.is_last;
484488
}
485489
inline bool operator!=(const ErrorMsg& lhs, const ErrorMsg& rhs) {
486490
return !(lhs == rhs);
487491
}
488492

489493
inline bool operator==(const SystemMsg& lhs, const SystemMsg& rhs) {
490-
return lhs.hd == rhs.hd && lhs.msg == rhs.msg;
494+
return lhs.hd == rhs.hd && lhs.msg == rhs.msg && lhs.code == rhs.code;
491495
}
492496
inline bool operator!=(const SystemMsg& lhs, const SystemMsg& rhs) {
493497
return !(lhs == rhs);

pkg/PKGBUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Maintainer: Databento <support@databento.com>
22
_pkgname=databento-cpp
33
pkgname=databento-cpp-git
4-
pkgver=0.14.1
4+
pkgver=0.15.0
55
pkgrel=1
66
pkgdesc="Official C++ client for Databento"
77
arch=('any')

src/compat.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ InstrumentDefMsgV2 InstrumentDefMsgV1::ToV2() const {
9292
return ret;
9393
}
9494

95+
ErrorMsgV2 ErrorMsgV1::ToV2() const {
96+
ErrorMsgV2 ret{
97+
RecordHeader{sizeof(ErrorMsgV2) / RecordHeader::kLengthMultiplier,
98+
RType::Error, hd.publisher_id, hd.instrument_id},
99+
{},
100+
std::numeric_limits<std::uint8_t>::max(),
101+
std::numeric_limits<std::uint8_t>::max()};
102+
std::copy(err.begin(), err.end(), ret.err.begin());
103+
return ret;
104+
}
105+
95106
SymbolMappingMsgV2 SymbolMappingMsgV1::ToV2() const {
96107
SymbolMappingMsgV2 ret{
97108
RecordHeader{sizeof(SymbolMappingMsgV2) / RecordHeader::kLengthMultiplier,
@@ -111,6 +122,16 @@ SymbolMappingMsgV2 SymbolMappingMsgV1::ToV2() const {
111122
return ret;
112123
}
113124

125+
SystemMsgV2 SystemMsgV1::ToV2() const {
126+
SystemMsgV2 ret{
127+
RecordHeader{sizeof(SystemMsgV2) / RecordHeader::kLengthMultiplier,
128+
RType::System, hd.publisher_id, hd.instrument_id},
129+
{},
130+
std::numeric_limits<std::uint8_t>::max()};
131+
std::copy(msg.begin(), msg.end(), ret.msg.begin());
132+
return ret;
133+
}
134+
114135
bool operator==(const InstrumentDefMsgV1& lhs, const InstrumentDefMsgV1& rhs) {
115136
return lhs.hd == rhs.hd && lhs.ts_recv == rhs.ts_recv &&
116137
lhs.min_price_increment == rhs.min_price_increment &&
@@ -245,6 +266,16 @@ std::ostream& operator<<(std::ostream& stream,
245266
.AddField("tick_rule", instr_def_msg.tick_rule)
246267
.Finish();
247268
}
269+
std::string ToString(const ErrorMsgV1& err_msg) { return MakeString(err_msg); }
270+
std::ostream& operator<<(std::ostream& stream, const ErrorMsgV1& err_msg) {
271+
return StreamOpBuilder{stream}
272+
.SetSpacer("\n ")
273+
.SetTypeName("ErrorMsgV1")
274+
.Build()
275+
.AddField("hd", err_msg.hd)
276+
.AddField("err", err_msg.err)
277+
.Finish();
278+
}
248279
std::string ToString(const SymbolMappingMsgV1& symbol_mapping_msg) {
249280
return MakeString(symbol_mapping_msg);
250281
}
@@ -261,4 +292,16 @@ std::ostream& operator<<(std::ostream& stream,
261292
.AddField("end_ts", symbol_mapping_msg.end_ts)
262293
.Finish();
263294
}
295+
std::string ToString(const SystemMsgV1& system_msg) {
296+
return MakeString(system_msg);
297+
}
298+
std::ostream& operator<<(std::ostream& stream, const SystemMsgV1& system_msg) {
299+
return StreamOpBuilder{stream}
300+
.SetSpacer("\n ")
301+
.SetTypeName("SystemMsgV1")
302+
.Build()
303+
.AddField("hd", system_msg.hd)
304+
.AddField("msg", system_msg.msg)
305+
.Finish();
306+
}
264307
} // namespace databento

src/record.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ std::ostream& operator<<(std::ostream& stream, const ErrorMsg& err_msg) {
467467
.Build()
468468
.AddField("hd", err_msg.hd)
469469
.AddField("err", err_msg.err)
470+
.AddField("code", err_msg.code)
471+
.AddField("is_last", err_msg.is_last)
470472
.Finish();
471473
}
472474

@@ -480,6 +482,7 @@ std::ostream& operator<<(std::ostream& stream, const SystemMsg& system_msg) {
480482
.Build()
481483
.AddField("hd", system_msg.hd)
482484
.AddField("msg", system_msg.msg)
485+
.AddField("code", system_msg.code)
483486
.Finish();
484487
}
485488

0 commit comments

Comments
 (0)