[pbs-devel] [PATCH v3 proxmox-backup 16/58] client: backup writer: only borrow http client

Christian Ebner c.ebner at proxmox.com
Thu Mar 28 13:36:25 CET 2024


Instead of taking ownership of the http client when starting a new
BackupWriter instance, only borrow the client.

This allows to reuse the http client to later reuse it to start also a
BackupReader instance as required for backup runs with metadata based
file change detection mode, where both must use the same http client.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
changes since version 2:
- not present in previous version

 examples/upload-speed.rs               | 2 +-
 pbs-client/src/backup_writer.rs        | 2 +-
 proxmox-backup-client/src/benchmark.rs | 2 +-
 proxmox-backup-client/src/main.rs      | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/examples/upload-speed.rs b/examples/upload-speed.rs
index f9fc52a85..e4b570ec5 100644
--- a/examples/upload-speed.rs
+++ b/examples/upload-speed.rs
@@ -18,7 +18,7 @@ async fn upload_speed() -> Result<f64, Error> {
     let backup_time = proxmox_time::epoch_i64();
 
     let client = BackupWriter::start(
-        client,
+        &client,
         None,
         datastore,
         &BackupNamespace::root(),
diff --git a/pbs-client/src/backup_writer.rs b/pbs-client/src/backup_writer.rs
index 8a03d8ea6..8bd0e4f36 100644
--- a/pbs-client/src/backup_writer.rs
+++ b/pbs-client/src/backup_writer.rs
@@ -78,7 +78,7 @@ impl BackupWriter {
     // FIXME: extract into (flattened) parameter struct?
     #[allow(clippy::too_many_arguments)]
     pub async fn start(
-        client: HttpClient,
+        client: &HttpClient,
         crypt_config: Option<Arc<CryptConfig>>,
         datastore: &str,
         ns: &BackupNamespace,
diff --git a/proxmox-backup-client/src/benchmark.rs b/proxmox-backup-client/src/benchmark.rs
index b3047308c..1262fb46d 100644
--- a/proxmox-backup-client/src/benchmark.rs
+++ b/proxmox-backup-client/src/benchmark.rs
@@ -229,7 +229,7 @@ async fn test_upload_speed(
 
     log::debug!("Connecting to backup server");
     let client = BackupWriter::start(
-        client,
+        &client,
         crypt_config.clone(),
         repo.store(),
         &BackupNamespace::root(),
diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
index 546275cb1..148708976 100644
--- a/proxmox-backup-client/src/main.rs
+++ b/proxmox-backup-client/src/main.rs
@@ -834,7 +834,7 @@ async fn create_backup(
 
     let backup_time = backup_time_opt.unwrap_or_else(epoch_i64);
 
-    let client = connect_rate_limited(&repo, rate_limit)?;
+    let http_client = connect_rate_limited(&repo, rate_limit)?;
     record_repository(&repo);
 
     let snapshot = BackupDir::from((backup_type, backup_id.to_owned(), backup_time));
@@ -886,7 +886,7 @@ async fn create_backup(
     };
 
     let client = BackupWriter::start(
-        client,
+        &http_client,
         crypt_config.clone(),
         repo.store(),
         &backup_ns,
-- 
2.39.2





More information about the pbs-devel mailing list