[pbs-devel] [PATCH v5 proxmox-backup 40/62] client: chunk stream: add struct to hold injection state

Christian Ebner c.ebner at proxmox.com
Tue May 7 17:52:22 CEST 2024


Adds a dedicated structure to hold the optional sender and receiver
instances and state for injection of reused dynamic entries in the
payload stream for split stream pxar archives.

The asynchronous channels must only be attached to the payload
archive, leaving the current behaviour for the metadata archive and
current default encoding without reusing payload chunks of previous
snapshots.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
changes since version 4:
- no changes

 pbs-client/src/chunk_stream.rs | 23 +++++++++++++++++++++++
 pbs-client/src/lib.rs          |  2 +-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/pbs-client/src/chunk_stream.rs b/pbs-client/src/chunk_stream.rs
index 895f6eae2..83c75ba28 100644
--- a/pbs-client/src/chunk_stream.rs
+++ b/pbs-client/src/chunk_stream.rs
@@ -1,4 +1,5 @@
 use std::pin::Pin;
+use std::sync::mpsc;
 use std::task::{Context, Poll};
 
 use anyhow::Error;
@@ -8,6 +9,28 @@ use futures::stream::{Stream, TryStream};
 
 use pbs_datastore::Chunker;
 
+use crate::inject_reused_chunks::InjectChunks;
+
+/// Holds the queues for optional injection of reused dynamic index entries
+pub struct InjectionData {
+    boundaries: mpsc::Receiver<InjectChunks>,
+    injections: mpsc::Sender<InjectChunks>,
+    consumed: u64,
+}
+
+impl InjectionData {
+    pub fn new(
+        boundaries: mpsc::Receiver<InjectChunks>,
+        injections: mpsc::Sender<InjectChunks>,
+    ) -> Self {
+        Self {
+            boundaries,
+            injections,
+            consumed: 0,
+        }
+    }
+}
+
 /// Split input stream into dynamic sized chunks
 pub struct ChunkStream<S: Unpin> {
     input: S,
diff --git a/pbs-client/src/lib.rs b/pbs-client/src/lib.rs
index 3e7bd2a8b..3d2da27b9 100644
--- a/pbs-client/src/lib.rs
+++ b/pbs-client/src/lib.rs
@@ -39,6 +39,6 @@ mod backup_specification;
 pub use backup_specification::*;
 
 mod chunk_stream;
-pub use chunk_stream::{ChunkStream, FixedChunkStream};
+pub use chunk_stream::{ChunkStream, FixedChunkStream, InjectionData};
 
 pub const PROXMOX_BACKUP_TCP_KEEPALIVE_TIME: u32 = 120;
-- 
2.39.2





More information about the pbs-devel mailing list