reduct_base/msg/
replication_api.rs

1// Copyright 2024 ReductSoftware UG
2// This Source Code Form is subject to the terms of the Mozilla Public
3//    License, v. 2.0. If a copy of the MPL was not distributed with this
4//    file, You can obtain one at https://mozilla.org/MPL/2.0/.
5use crate::msg::diagnostics::Diagnostics;
6use crate::Labels;
7use serde::{Deserialize, Serialize};
8use serde_json::Value;
9
10/// Replication settings
11#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default)]
12pub struct ReplicationSettings {
13    /// Source bucket
14    pub src_bucket: String,
15    /// Destination bucket
16    pub dst_bucket: String,
17    /// Destination host URL (e.g. https://reductstore.com)
18    pub dst_host: String,
19    /// Destination access token
20    pub dst_token: Option<String>,
21    /// Entries to replicate. If empty, all entries are replicated. Wildcards are supported.
22    #[serde(default)]
23    pub entries: Vec<String>,
24    /// Labels to include
25    #[serde(default)]
26    pub include: Labels,
27    /// Labels to exclude
28    #[serde(default)]
29    pub exclude: Labels,
30    /// Replication each N-th record
31    #[serde(default)]
32    pub each_n: Option<u64>,
33    /// Replication a record every S seconds
34    #[serde(default)]
35    pub each_s: Option<f64>,
36    /// When condition
37    #[serde(default)]
38    pub when: Option<Value>,
39}
40
41/// Replication info
42#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
43pub struct ReplicationInfo {
44    /// Replication name
45    pub name: String,
46    /// Remote instance is available and replication is active
47    pub is_active: bool,
48    /// Replication is provisioned
49    pub is_provisioned: bool,
50    /// Number of records pending replication
51    pub pending_records: u64,
52}
53
54/// Replication list
55#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default)]
56pub struct ReplicationList {
57    /// Replication list
58    pub replications: Vec<ReplicationInfo>,
59}
60
61/// Replication settings
62#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
63pub struct FullReplicationInfo {
64    /// Info
65    pub info: ReplicationInfo,
66    /// Settings
67    pub settings: ReplicationSettings,
68    /// Diagnostics
69    pub diagnostics: Diagnostics,
70}