From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id C62521FF161 for ; Sat, 19 Jul 2025 14:50:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 35996AB02; Sat, 19 Jul 2025 14:51:17 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Sat, 19 Jul 2025 14:49:49 +0200 Message-ID: <20250719125035.9926-4-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250719125035.9926-1-c.ebner@proxmox.com> References: <20250719125035.9926-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1752929439572 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.044 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox v9 3/3] s3 client: wrap upload with retry into dedicated methods X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" The `replace` boolean flag in the upload_with_retry() method signature unfortunately is not very ergonomic and hinders code readability. Therefore, wrap the method into helpers covering both variants, encoding their behaviour in the method name instead. As the client is currently only used by the Proxmox Backup Server's s3 backend, the code not being applied just yet, it is fine to drop the previous public method althogehter without much further adaptions. Signed-off-by: Christian Ebner --- changes since version 8: - not present in previous version proxmox-s3-client/src/client.rs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/proxmox-s3-client/src/client.rs b/proxmox-s3-client/src/client.rs index 08e45ebf..5e9d7cb2 100644 --- a/proxmox-s3-client/src/client.rs +++ b/proxmox-s3-client/src/client.rs @@ -585,8 +585,36 @@ impl S3Client { Ok(delete_errors) } - /// Upload the given object via the S3 api, retrying up to 3 times in case of error. - pub async fn upload_with_retry( + /// Upload the given object via the S3 api, not replacing it if already present in the object + /// store. + /// Retrying up to 3 times in case of error. + #[inline(always)] + pub async fn upload_no_replace_with_retry( + &self, + object_key: S3ObjectKey, + object_data: Bytes, + ) -> Result { + let replace = false; + self.do_upload_with_retry(object_key, object_data, replace) + .await + } + + /// Upload the given object via the S3 api, replacing it if already present in the object store. + /// Retrying up to 3 times in case of error. + #[inline(always)] + pub async fn upload_replace_with_retry( + &self, + object_key: S3ObjectKey, + object_data: Bytes, + ) -> Result { + let replace = true; + self.do_upload_with_retry(object_key, object_data, replace) + .await + } + + /// Helper to perform the object upload and retry, wrapped by the corresponding methods + /// to mask the `replace` flag. + async fn do_upload_with_retry( &self, object_key: S3ObjectKey, object_data: Bytes, -- 2.47.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel