ORE Studio 0.0.4
Loading...
Searching...
No Matches
publish_bundle_protocol.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 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_PUBLISH_BUNDLE_PROTOCOL_HPP
21#define ORES_DQ_MESSAGING_PUBLISH_BUNDLE_PROTOCOL_HPP
22
23#include <span>
24#include <iosfwd>
25#include <vector>
26#include <expected>
27#include "ores.comms/messaging/message_types.hpp"
28#include "ores.comms/messaging/message_traits.hpp"
29#include "ores.dq/domain/publication_mode.hpp"
30
31namespace ores::dq::messaging {
32
37 std::string dataset_code;
38 std::string dataset_name;
39 std::string status; // "success", "failed", "skipped"
40 std::uint64_t records_inserted = 0;
41 std::uint64_t records_updated = 0;
42 std::uint64_t records_skipped = 0;
43 std::uint64_t records_deleted = 0;
44 std::string error_message;
45
46 std::vector<std::byte> serialize() const;
47 static std::expected<bundle_dataset_result, ores::utility::serialization::error_code>
48 deserialize(std::span<const std::byte>& data);
49};
50
51std::ostream& operator<<(std::ostream& s, const bundle_dataset_result& v);
52
65 std::string bundle_code;
66
75 domain::publication_mode mode = domain::publication_mode::upsert;
76
80 std::string published_by;
81
88 bool atomic = true;
89
101 std::vector<std::byte> serialize() const;
102
106 static std::expected<publish_bundle_request,
107 ores::utility::serialization::error_code>
108 deserialize(std::span<const std::byte> data);
109};
110
111std::ostream& operator<<(std::ostream& s, const publish_bundle_request& v);
112
123 bool success = false;
124
128 std::string error_message;
129
133 std::uint32_t datasets_processed = 0;
134
138 std::uint32_t datasets_succeeded = 0;
139
143 std::uint32_t datasets_failed = 0;
144
148 std::uint32_t datasets_skipped = 0;
149
153 std::uint64_t total_records_inserted = 0;
154
158 std::uint64_t total_records_updated = 0;
159
163 std::uint64_t total_records_skipped = 0;
164
168 std::uint64_t total_records_deleted = 0;
169
173 std::vector<bundle_dataset_result> dataset_results;
174
193 std::vector<std::byte> serialize() const;
194
198 static std::expected<publish_bundle_response,
199 ores::utility::serialization::error_code>
200 deserialize(std::span<const std::byte> data);
201};
202
203std::ostream& operator<<(std::ostream& s, const publish_bundle_response& v);
204
205}
206
207namespace ores::comms::messaging {
208
212template<>
213struct message_traits<dq::messaging::publish_bundle_request> {
216 static constexpr message_type request_message_type =
217 message_type::publish_bundle_request;
218};
219
220}
221
222#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
Result for a single dataset within a bundle publication.
Definition publish_bundle_protocol.hpp:36
Request to publish all datasets in a bundle.
Definition publish_bundle_protocol.hpp:61
std::string published_by
Username of person initiating publication.
Definition publish_bundle_protocol.hpp:80
std::string bundle_code
Code of the bundle to publish (e.g., 'base', 'solvaris').
Definition publish_bundle_protocol.hpp:65
std::vector< std::byte > serialize() const
Serialize request to bytes.
Definition publish_bundle_protocol.cpp:98
bool atomic
If true, first failure causes entire bundle to rollback.
Definition publish_bundle_protocol.hpp:88
static std::expected< publish_bundle_request, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize request from bytes.
Definition publish_bundle_protocol.cpp:108
domain::publication_mode mode
Publication mode.
Definition publish_bundle_protocol.hpp:75
Response containing results of bundle publication.
Definition publish_bundle_protocol.hpp:116
std::uint32_t datasets_succeeded
Number of datasets successfully published.
Definition publish_bundle_protocol.hpp:138
std::uint64_t total_records_deleted
Total records deleted across all datasets.
Definition publish_bundle_protocol.hpp:168
static std::expected< publish_bundle_response, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize response from bytes.
Definition publish_bundle_protocol.cpp:164
std::vector< std::byte > serialize() const
Serialize response to bytes.
Definition publish_bundle_protocol.cpp:139
std::uint32_t datasets_processed
Number of datasets processed.
Definition publish_bundle_protocol.hpp:133
std::uint32_t datasets_skipped
Number of datasets skipped.
Definition publish_bundle_protocol.hpp:148
bool success
Overall success flag.
Definition publish_bundle_protocol.hpp:123
std::uint64_t total_records_inserted
Total records inserted across all datasets.
Definition publish_bundle_protocol.hpp:153
std::uint64_t total_records_updated
Total records updated across all datasets.
Definition publish_bundle_protocol.hpp:158
std::string error_message
Error message if overall publication failed.
Definition publish_bundle_protocol.hpp:128
std::uint64_t total_records_skipped
Total records skipped across all datasets.
Definition publish_bundle_protocol.hpp:163
std::uint32_t datasets_failed
Number of datasets that failed.
Definition publish_bundle_protocol.hpp:143
std::vector< bundle_dataset_result > dataset_results
Per-dataset publication results.
Definition publish_bundle_protocol.hpp:173