ORE Studio 0.0.4
Loading...
Searching...
No Matches
telemetry_protocol.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_TELEMETRY_MESSAGING_TELEMETRY_PROTOCOL_HPP
21#define ORES_TELEMETRY_MESSAGING_TELEMETRY_PROTOCOL_HPP
22
23#include <span>
24#include <iosfwd>
25#include <vector>
26#include <cstdint>
27#include <expected>
28#include "ores.comms/messaging/message_types.hpp"
29#include "ores.comms/messaging/message_traits.hpp"
30#include "ores.telemetry/domain/telemetry_log_entry.hpp"
31#include "ores.telemetry/domain/telemetry_batch.hpp"
32#include "ores.telemetry/domain/telemetry_query.hpp"
33#include "ores.telemetry/domain/telemetry_stats.hpp"
34
36
47 bool success = true;
48
52 std::uint32_t entries_accepted = 0;
53
57 std::string message;
58
59 std::vector<std::byte> serialize() const;
60 static std::expected<submit_telemetry_response, ores::utility::serialization::error_code>
61 deserialize(std::span<const std::byte> data);
62};
63
64std::ostream& operator<<(std::ostream& s, const submit_telemetry_response& v);
65
77
78 std::vector<std::byte> serialize() const;
79 static std::expected<get_telemetry_logs_request, ores::utility::serialization::error_code>
80 deserialize(std::span<const std::byte> data);
81};
82
83std::ostream& operator<<(std::ostream& s, const get_telemetry_logs_request& v);
84
92 bool success = true;
93
97 std::vector<domain::telemetry_log_entry> entries;
98
102 std::uint64_t total_count = 0;
103
107 std::string message;
108
109 std::vector<std::byte> serialize() const;
110 static std::expected<get_telemetry_logs_response, ores::utility::serialization::error_code>
111 deserialize(std::span<const std::byte> data);
112};
113
114std::ostream& operator<<(std::ostream& s, const get_telemetry_logs_response& v);
115
127
128 std::vector<std::byte> serialize() const;
129 static std::expected<get_telemetry_stats_request, ores::utility::serialization::error_code>
130 deserialize(std::span<const std::byte> data);
131};
132
133std::ostream& operator<<(std::ostream& s, const get_telemetry_stats_request& v);
134
142 bool success = true;
143
147 std::vector<domain::telemetry_stats> stats;
148
152 std::string message;
153
154 std::vector<std::byte> serialize() const;
155 static std::expected<get_telemetry_stats_response, ores::utility::serialization::error_code>
156 deserialize(std::span<const std::byte> data);
157};
158
159std::ostream& operator<<(std::ostream& s, const get_telemetry_stats_response& v);
160
161}
162
163namespace ores::comms::messaging {
164
168template<>
169struct message_traits<telemetry::messaging::get_telemetry_logs_request> {
172 static constexpr message_type request_message_type =
173 message_type::get_telemetry_logs_request;
174};
175
179template<>
180struct message_traits<telemetry::messaging::get_telemetry_stats_request> {
183 static constexpr message_type request_message_type =
184 message_type::get_telemetry_stats_request;
185};
186
187}
188
189#endif
Contains messaging related infrastructure in the comms library.
Definition assets_protocol.hpp:122
Network messaging protocol for log records.
Definition telemetry_message_handler.cpp:27
std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > &stream, boost_severity level)
Inserter for boost_severity enum.
Definition boost_severity.hpp:80
Traits template for mapping request types to their response types and message type enum values.
Definition message_traits.hpp:66
Query parameters for retrieving telemetry logs.
Definition telemetry_query.hpp:38
Query parameters for retrieving telemetry statistics.
Definition telemetry_query.hpp:140
Response to submit_log_records_request.
Definition telemetry_protocol.hpp:43
std::string message
Optional error message if some entries failed.
Definition telemetry_protocol.hpp:57
bool success
Whether the submission was successful.
Definition telemetry_protocol.hpp:47
std::uint32_t entries_accepted
Number of entries that were accepted and persisted.
Definition telemetry_protocol.hpp:52
Request to retrieve telemetry log entries.
Definition telemetry_protocol.hpp:72
domain::telemetry_query query
Query parameters.
Definition telemetry_protocol.hpp:76
Response containing telemetry log entries.
Definition telemetry_protocol.hpp:88
std::uint64_t total_count
Total count of matching entries (for pagination).
Definition telemetry_protocol.hpp:102
std::vector< domain::telemetry_log_entry > entries
The log entries matching the query.
Definition telemetry_protocol.hpp:97
std::string message
Error message if query failed.
Definition telemetry_protocol.hpp:107
bool success
Whether the query was successful.
Definition telemetry_protocol.hpp:92
Request to retrieve telemetry statistics.
Definition telemetry_protocol.hpp:122
domain::telemetry_stats_query query
Query parameters.
Definition telemetry_protocol.hpp:126
Response containing telemetry statistics.
Definition telemetry_protocol.hpp:138
std::vector< domain::telemetry_stats > stats
The aggregated statistics.
Definition telemetry_protocol.hpp:147
std::string message
Error message if query failed.
Definition telemetry_protocol.hpp:152
bool success
Whether the query was successful.
Definition telemetry_protocol.hpp:142