ORE Studio 0.0.4
Loading...
Searching...
No Matches
publication_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_PUBLICATION_PROTOCOL_HPP
21#define ORES_DQ_MESSAGING_PUBLICATION_PROTOCOL_HPP
22
23#include <span>
24#include <iosfwd>
25#include <vector>
26#include <expected>
27#include <boost/uuid/uuid.hpp>
28#include "ores.comms/messaging/message_types.hpp"
29#include "ores.comms/messaging/message_traits.hpp"
30#include "ores.dq/domain/dataset.hpp"
31#include "ores.dq/domain/publication.hpp"
32#include "ores.dq/domain/publication_mode.hpp"
33#include "ores.dq/domain/publication_result.hpp"
34
35namespace ores::dq::messaging {
36
37// ============================================================================
38// Publication Messages
39// ============================================================================
40
54 std::vector<boost::uuids::uuid> dataset_ids;
55
64 domain::publication_mode mode = domain::publication_mode::upsert;
65
69 std::string published_by;
70
75
82 bool atomic = true;
83
96 std::vector<std::byte> serialize() const;
97
101 static std::expected<publish_datasets_request,
102 ores::utility::serialization::error_code>
103 deserialize(std::span<const std::byte> data);
104};
105
106std::ostream& operator<<(std::ostream& s, const publish_datasets_request& v);
107
118 std::vector<domain::publication_result> results;
119
141 std::vector<std::byte> serialize() const;
142
146 static std::expected<publish_datasets_response,
147 ores::utility::serialization::error_code>
148 deserialize(std::span<const std::byte> data);
149};
150
151std::ostream& operator<<(std::ostream& s, const publish_datasets_response& v);
152
153// ============================================================================
154// Publication History Messages
155// ============================================================================
156
169 boost::uuids::uuid dataset_id;
170
174 std::uint32_t limit = 100;
175
183 std::vector<std::byte> serialize() const;
184
188 static std::expected<get_publications_request,
189 ores::utility::serialization::error_code>
190 deserialize(std::span<const std::byte> data);
191};
192
193std::ostream& operator<<(std::ostream& s, const get_publications_request& v);
194
202 std::vector<domain::publication> publications;
203
225 std::vector<std::byte> serialize() const;
226
230 static std::expected<get_publications_response,
231 ores::utility::serialization::error_code>
232 deserialize(std::span<const std::byte> data);
233};
234
235std::ostream& operator<<(std::ostream& s, const get_publications_response& v);
236
237// ============================================================================
238// Dependency Resolution Messages
239// ============================================================================
240
252 std::vector<boost::uuids::uuid> dataset_ids;
253
261 std::vector<std::byte> serialize() const;
262
266 static std::expected<resolve_dependencies_request,
267 ores::utility::serialization::error_code>
268 deserialize(std::span<const std::byte> data);
269};
270
271std::ostream& operator<<(std::ostream& s, const resolve_dependencies_request& v);
272
286 std::vector<domain::dataset> datasets;
287
294 std::vector<boost::uuids::uuid> requested_ids;
295
305 std::vector<std::byte> serialize() const;
306
310 static std::expected<resolve_dependencies_response,
311 ores::utility::serialization::error_code>
312 deserialize(std::span<const std::byte> data);
313};
314
315std::ostream& operator<<(std::ostream& s, const resolve_dependencies_response& v);
316
317}
318
319namespace ores::comms::messaging {
320
324template<>
325struct message_traits<dq::messaging::publish_datasets_request> {
328 static constexpr message_type request_message_type =
329 message_type::publish_datasets_request;
330};
331
335template<>
336struct message_traits<dq::messaging::get_publications_request> {
339 static constexpr message_type request_message_type =
340 message_type::get_publications_request;
341};
342
346template<>
347struct message_traits<dq::messaging::resolve_dependencies_request> {
350 static constexpr message_type request_message_type =
351 message_type::resolve_dependencies_request;
352};
353
354}
355
356#endif
Contains messaging related infrastructure in the comms library.
Definition assets_protocol.hpp:122
Traits template for mapping request types to their response types and message type enum values.
Definition message_traits.hpp:66
Request to publish one or more datasets to production tables.
Definition publication_protocol.hpp:50
std::string published_by
Username of person initiating publication.
Definition publication_protocol.hpp:69
std::vector< std::byte > serialize() const
Serialize request to bytes.
Definition publication_protocol.cpp:110
std::vector< boost::uuids::uuid > dataset_ids
IDs of datasets to publish.
Definition publication_protocol.hpp:54
bool resolve_dependencies
If true, automatically include and publish dependencies first.
Definition publication_protocol.hpp:74
bool atomic
If true, first failure causes entire publication to abort.
Definition publication_protocol.hpp:82
static std::expected< publish_datasets_request, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize request from bytes.
Definition publication_protocol.cpp:135
domain::publication_mode mode
Publication mode.
Definition publication_protocol.hpp:64
Response containing results of dataset publication.
Definition publication_protocol.hpp:111
std::vector< std::byte > serialize() const
Serialize response to bytes.
Definition publication_protocol.cpp:183
std::vector< domain::publication_result > results
Results for each dataset published.
Definition publication_protocol.hpp:118
static std::expected< publish_datasets_response, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize response from bytes.
Definition publication_protocol.cpp:198
Request to get publication history.
Definition publication_protocol.hpp:163
std::uint32_t limit
Maximum number of records to return.
Definition publication_protocol.hpp:174
static std::expected< get_publications_request, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize request from bytes.
Definition publication_protocol.cpp:234
std::vector< std::byte > serialize() const
Serialize request to bytes.
Definition publication_protocol.cpp:226
boost::uuids::uuid dataset_id
Optional dataset ID to filter by.
Definition publication_protocol.hpp:169
Response containing publication history.
Definition publication_protocol.hpp:198
std::vector< std::byte > serialize() const
Serialize response to bytes.
Definition publication_protocol.cpp:332
static std::expected< get_publications_response, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize response from bytes.
Definition publication_protocol.cpp:347
std::vector< domain::publication > publications
Publication records, newest first.
Definition publication_protocol.hpp:202
Request to resolve dependencies for datasets before publishing.
Definition publication_protocol.hpp:248
std::vector< std::byte > serialize() const
Serialize request to bytes.
Definition publication_protocol.cpp:375
std::vector< boost::uuids::uuid > dataset_ids
IDs of datasets to resolve dependencies for.
Definition publication_protocol.hpp:252
static std::expected< resolve_dependencies_request, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize request from bytes.
Definition publication_protocol.cpp:388
Response containing the resolved publication order.
Definition publication_protocol.hpp:279
std::vector< domain::dataset > datasets
Datasets in publication order.
Definition publication_protocol.hpp:286
std::vector< std::byte > serialize() const
Serialize response to bytes.
Definition publication_protocol.cpp:416
static std::expected< resolve_dependencies_response, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize response from bytes.
Definition publication_protocol.cpp:439
std::vector< boost::uuids::uuid > requested_ids
IDs of datasets that were explicitly requested (not dependencies).
Definition publication_protocol.hpp:294