ORE Studio 0.0.4
Loading...
Searching...
No Matches
dataset_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_DQ_MESSAGING_DATASET_PROTOCOL_HPP
21#define ORES_DQ_MESSAGING_DATASET_PROTOCOL_HPP
22
23#include <cstddef>
24#include <span>
25#include <iosfwd>
26#include <vector>
27#include <expected>
28#include <boost/uuid/uuid.hpp>
29#include "ores.comms/messaging/message_types.hpp"
30#include "ores.comms/messaging/message_traits.hpp"
31#include "ores.dq/domain/dataset.hpp"
32#include "ores.dq/domain/methodology.hpp"
33#include "ores.utility/serialization/error_code.hpp"
34
35namespace ores::dq::messaging {
36
37// ============================================================================
38// Dataset Serialization Helpers
39// ============================================================================
40
47void write_dataset(std::vector<std::byte>& buffer, const domain::dataset& d);
48
52std::expected<domain::dataset, ores::utility::serialization::error_code>
53read_dataset(std::span<const std::byte>& data);
54
55// ============================================================================
56// Dataset Messages
57// ============================================================================
58
63 std::vector<std::byte> serialize() const;
64 static std::expected<get_datasets_request,
65 ores::utility::serialization::error_code>
66 deserialize(std::span<const std::byte> data);
67};
68
69std::ostream& operator<<(std::ostream& s, const get_datasets_request& v);
70
75 std::vector<domain::dataset> datasets;
76
77 std::vector<std::byte> serialize() const;
78 static std::expected<get_datasets_response,
79 ores::utility::serialization::error_code>
80 deserialize(std::span<const std::byte> data);
81};
82
83std::ostream& operator<<(std::ostream& s, const get_datasets_response& v);
84
89 domain::dataset dataset;
90
91 std::vector<std::byte> serialize() const;
92 static std::expected<save_dataset_request,
93 ores::utility::serialization::error_code>
94 deserialize(std::span<const std::byte> data);
95};
96
97std::ostream& operator<<(std::ostream& s, const save_dataset_request& v);
98
103 bool success;
104 std::string message;
105
106 std::vector<std::byte> serialize() const;
107 static std::expected<save_dataset_response,
108 ores::utility::serialization::error_code>
109 deserialize(std::span<const std::byte> data);
110};
111
112std::ostream& operator<<(std::ostream& s, const save_dataset_response& v);
113
118 boost::uuids::uuid id;
119 bool success;
120 std::string message;
121};
122
123std::ostream& operator<<(std::ostream& s, const delete_dataset_result& v);
124
129 std::vector<boost::uuids::uuid> ids;
130
131 std::vector<std::byte> serialize() const;
132 static std::expected<delete_dataset_request,
133 ores::utility::serialization::error_code>
134 deserialize(std::span<const std::byte> data);
135};
136
137std::ostream& operator<<(std::ostream& s, const delete_dataset_request& v);
138
143 std::vector<delete_dataset_result> results;
144
145 std::vector<std::byte> serialize() const;
146 static std::expected<delete_dataset_response,
147 ores::utility::serialization::error_code>
148 deserialize(std::span<const std::byte> data);
149};
150
151std::ostream& operator<<(std::ostream& s, const delete_dataset_response& v);
152
157 boost::uuids::uuid id;
158
159 std::vector<std::byte> serialize() const;
160 static std::expected<get_dataset_history_request,
161 ores::utility::serialization::error_code>
162 deserialize(std::span<const std::byte> data);
163};
164
165std::ostream& operator<<(std::ostream& s, const get_dataset_history_request& v);
166
171 bool success;
172 std::string message;
173 std::vector<domain::dataset> versions;
174
175 std::vector<std::byte> serialize() const;
176 static std::expected<get_dataset_history_response,
177 ores::utility::serialization::error_code>
178 deserialize(std::span<const std::byte> data);
179};
180
181std::ostream& operator<<(std::ostream& s, const get_dataset_history_response& v);
182
183// ============================================================================
184// Methodology Messages
185// ============================================================================
186
191 std::vector<std::byte> serialize() const;
192 static std::expected<get_methodologies_request,
193 ores::utility::serialization::error_code>
194 deserialize(std::span<const std::byte> data);
195};
196
197std::ostream& operator<<(std::ostream& s, const get_methodologies_request& v);
198
203 std::vector<domain::methodology> methodologies;
204
205 std::vector<std::byte> serialize() const;
206 static std::expected<get_methodologies_response,
207 ores::utility::serialization::error_code>
208 deserialize(std::span<const std::byte> data);
209};
210
211std::ostream& operator<<(std::ostream& s, const get_methodologies_response& v);
212
217 domain::methodology methodology;
218
219 std::vector<std::byte> serialize() const;
220 static std::expected<save_methodology_request,
221 ores::utility::serialization::error_code>
222 deserialize(std::span<const std::byte> data);
223};
224
225std::ostream& operator<<(std::ostream& s, const save_methodology_request& v);
226
231 bool success;
232 std::string message;
233
234 std::vector<std::byte> serialize() const;
235 static std::expected<save_methodology_response,
236 ores::utility::serialization::error_code>
237 deserialize(std::span<const std::byte> data);
238};
239
240std::ostream& operator<<(std::ostream& s, const save_methodology_response& v);
241
246 boost::uuids::uuid id;
247 bool success;
248 std::string message;
249};
250
251std::ostream& operator<<(std::ostream& s, const delete_methodology_result& v);
252
257 std::vector<boost::uuids::uuid> ids;
258
259 std::vector<std::byte> serialize() const;
260 static std::expected<delete_methodology_request,
261 ores::utility::serialization::error_code>
262 deserialize(std::span<const std::byte> data);
263};
264
265std::ostream& operator<<(std::ostream& s, const delete_methodology_request& v);
266
271 std::vector<delete_methodology_result> results;
272
273 std::vector<std::byte> serialize() const;
274 static std::expected<delete_methodology_response,
275 ores::utility::serialization::error_code>
276 deserialize(std::span<const std::byte> data);
277};
278
279std::ostream& operator<<(std::ostream& s, const delete_methodology_response& v);
280
285 boost::uuids::uuid id;
286
287 std::vector<std::byte> serialize() const;
288 static std::expected<get_methodology_history_request,
289 ores::utility::serialization::error_code>
290 deserialize(std::span<const std::byte> data);
291};
292
293std::ostream& operator<<(std::ostream& s, const get_methodology_history_request& v);
294
299 bool success;
300 std::string message;
301 std::vector<domain::methodology> versions;
302
303 std::vector<std::byte> serialize() const;
304 static std::expected<get_methodology_history_response,
305 ores::utility::serialization::error_code>
306 deserialize(std::span<const std::byte> data);
307};
308
309std::ostream& operator<<(std::ostream& s, const get_methodology_history_response& v);
310
311}
312
313namespace ores::comms::messaging {
314
315// Dataset traits
316template<>
317struct message_traits<dq::messaging::get_datasets_request> {
318 using request_type = dq::messaging::get_datasets_request;
319 using response_type = dq::messaging::get_datasets_response;
320 static constexpr message_type request_message_type =
321 message_type::get_datasets_request;
322};
323
324template<>
325struct message_traits<dq::messaging::save_dataset_request> {
326 using request_type = dq::messaging::save_dataset_request;
327 using response_type = dq::messaging::save_dataset_response;
328 static constexpr message_type request_message_type =
329 message_type::save_dataset_request;
330};
331
332template<>
333struct message_traits<dq::messaging::delete_dataset_request> {
334 using request_type = dq::messaging::delete_dataset_request;
335 using response_type = dq::messaging::delete_dataset_response;
336 static constexpr message_type request_message_type =
337 message_type::delete_dataset_request;
338};
339
340template<>
341struct message_traits<dq::messaging::get_dataset_history_request> {
342 using request_type = dq::messaging::get_dataset_history_request;
343 using response_type = dq::messaging::get_dataset_history_response;
344 static constexpr message_type request_message_type =
345 message_type::get_dataset_history_request;
346};
347
348// Methodology traits
349template<>
350struct message_traits<dq::messaging::get_methodologies_request> {
351 using request_type = dq::messaging::get_methodologies_request;
352 using response_type = dq::messaging::get_methodologies_response;
353 static constexpr message_type request_message_type =
354 message_type::get_methodologies_request;
355};
356
357template<>
358struct message_traits<dq::messaging::save_methodology_request> {
359 using request_type = dq::messaging::save_methodology_request;
360 using response_type = dq::messaging::save_methodology_response;
361 static constexpr message_type request_message_type =
362 message_type::save_methodology_request;
363};
364
365template<>
366struct message_traits<dq::messaging::delete_methodology_request> {
367 using request_type = dq::messaging::delete_methodology_request;
368 using response_type = dq::messaging::delete_methodology_response;
369 static constexpr message_type request_message_type =
370 message_type::delete_methodology_request;
371};
372
373template<>
374struct message_traits<dq::messaging::get_methodology_history_request> {
375 using request_type = dq::messaging::get_methodology_history_request;
376 using response_type = dq::messaging::get_methodology_history_response;
377 static constexpr message_type request_message_type =
378 message_type::get_methodology_history_request;
379};
380
381}
382
383#endif
Contains messaging related infrastructure in the comms library.
Definition assets_protocol.hpp:122
Represents a data quality dataset with lineage tracking.
Definition dataset.hpp:36
Describes a methodology for data processing or transformation.
Definition methodology.hpp:33
Request to retrieve all datasets.
Definition dataset_protocol.hpp:62
Response containing all datasets.
Definition dataset_protocol.hpp:74
Request to save a dataset (create or update).
Definition dataset_protocol.hpp:88
Response confirming dataset save operation.
Definition dataset_protocol.hpp:102
Result for a single dataset deletion.
Definition dataset_protocol.hpp:117
Request to delete one or more datasets.
Definition dataset_protocol.hpp:128
Response confirming dataset deletion(s).
Definition dataset_protocol.hpp:142
Request to retrieve version history for a dataset.
Definition dataset_protocol.hpp:156
Response containing dataset version history.
Definition dataset_protocol.hpp:170
Request to retrieve all methodologies.
Definition dataset_protocol.hpp:190
Response containing all methodologies.
Definition dataset_protocol.hpp:202
Request to save a methodology (create or update).
Definition dataset_protocol.hpp:216
Response confirming methodology save operation.
Definition dataset_protocol.hpp:230
Result for a single methodology deletion.
Definition dataset_protocol.hpp:245
Request to delete one or more methodologies.
Definition dataset_protocol.hpp:256
Response confirming methodology deletion(s).
Definition dataset_protocol.hpp:270
Request to retrieve version history for a methodology.
Definition dataset_protocol.hpp:284
Response containing methodology version history.
Definition dataset_protocol.hpp:298