all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Shan Shaji <s.shaji@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup 1/9] refactor: remove local `LogThrottle` in favor of proxmox-log
Date: Mon, 19 Oct 2026 18:03:51 +0200	[thread overview]
Message-ID: <20261019160359.20851-2-s.shaji@proxmox.com> (raw)
In-Reply-To: <20261019160359.20851-1-s.shaji@proxmox.com>

Remove the local implementation of `LogThrottle` and use the version
provided by the proxmox-log crate instead. This prepares the utility
for re-use in pbs-datastore and updates all existing references
accordingly. No functional changes.

Signed-off-by: Shan Shaji <s.shaji@proxmox.com>
---
 pbs-client/src/lib.rs             |  3 ---
 pbs-client/src/log_throttle.rs    | 36 -------------------------------
 proxmox-backup-client/src/main.rs |  3 ++-
 3 files changed, 2 insertions(+), 40 deletions(-)
 delete mode 100644 pbs-client/src/log_throttle.rs

diff --git a/pbs-client/src/lib.rs b/pbs-client/src/lib.rs
index 139f4f4b5..4b8e4e4f4 100644
--- a/pbs-client/src/lib.rs
+++ b/pbs-client/src/lib.rs
@@ -45,7 +45,4 @@ pub use chunk_stream::{ChunkStream, FixedChunkStream, InjectionData};
 mod backup_stats;
 pub use backup_stats::BackupStats;
 
-mod log_throttle;
-pub use log_throttle::LogThrottle;
-
 pub const PROXMOX_BACKUP_TCP_KEEPALIVE_TIME: u32 = 120;
diff --git a/pbs-client/src/log_throttle.rs b/pbs-client/src/log_throttle.rs
deleted file mode 100644
index cfaa6c494..000000000
--- a/pbs-client/src/log_throttle.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-use std::time::{Duration, Instant};
-
-/// Rate-limits recurring log output, such as progress lines, with an exponential backoff.
-///
-/// [`should_log`](Self::should_log) returns `true` at most once per the current interval. Starting
-/// from an initial interval, the delay doubles after each hit up to a configured maximum, giving
-/// frequent feedback early on while avoiding log spam during long-running operations.
-pub struct LogThrottle {
-    last: Instant,
-    interval: Duration,
-    max_interval: Duration,
-}
-
-impl LogThrottle {
-    /// Creates a throttle with the given initial interval, doubling up to `max_interval` after each
-    /// hit. The initial interval is capped at `max_interval`.
-    pub fn new(initial_interval: Duration, max_interval: Duration) -> Self {
-        Self {
-            last: Instant::now(),
-            interval: initial_interval.min(max_interval),
-            max_interval,
-        }
-    }
-
-    /// Returns `true` if the current interval has elapsed since the last hit, advancing the
-    /// throttle and doubling the interval (capped at the maximum); returns `false` otherwise.
-    pub fn should_log(&mut self) -> bool {
-        let now = Instant::now();
-        if now.duration_since(self.last) < self.interval {
-            return false;
-        }
-        self.last = now;
-        self.interval = (self.interval * 2).min(self.max_interval);
-        true
-    }
-}
diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
index 3e7aa7cfd..93f5a1b7a 100644
--- a/proxmox-backup-client/src/main.rs
+++ b/proxmox-backup-client/src/main.rs
@@ -18,6 +18,7 @@ use pathpatterns::{MatchEntry, MatchType, PatternFlag};
 use proxmox_async::blocking::TokioWriterAdapter;
 use proxmox_human_byte::HumanByte;
 use proxmox_io::StdChannelWriter;
+use proxmox_log::log_throttle::LogThrottle;
 use proxmox_router::{ApiMethod, RpcEnvironment, cli::*};
 use proxmox_schema::api;
 use proxmox_sys::fs::{CreateOptions, file_get_json, image_size, replace_file};
@@ -51,7 +52,7 @@ use pbs_client::{
     BACKUP_SOURCE_SCHEMA, BackupDetectionMode, BackupReader, BackupRepository,
     BackupRepositoryArgs, BackupSpecificationType, BackupStats, BackupTargetArgs, BackupWriter,
     BackupWriterOptions, ChunkStream, FixedChunkStream, HttpClient, IndexType, InjectionData,
-    LogThrottle, PxarBackupStream, RemoteChunkReader, UploadOptions, delete_ticket_info,
+    PxarBackupStream, RemoteChunkReader, UploadOptions, delete_ticket_info,
     parse_backup_specification, view_task_result,
 };
 use pbs_datastore::catalog::{BackupCatalogWriter, CatalogReader, CatalogWriter};
-- 
2.47.3





  reply	other threads:[~2026-10-19 16:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 16:03 [PATCH proxmox{-backup,} 0/9] fix #7903: rebuild local S3 chunk markers Shan Shaji
2026-10-19 16:03 ` Shan Shaji [this message]
2026-10-19 16:03 ` [PATCH proxmox-backup 2/9] datastore: factor out s3 chunk objects pagination into a helper Shan Shaji
2026-10-19 16:03 ` [PATCH proxmox-backup 3/9] pbs-datastore: inherit proxmox-log crate from workspace Shan Shaji
2026-10-19 16:03 ` [PATCH proxmox-backup 4/9] datastore: add method to create zero-byte chunk markers Shan Shaji
2026-10-19 16:03 ` [PATCH proxmox-backup 5/9] fix #7908: datastore: api: add option " Shan Shaji
2026-10-19 16:03 ` [PATCH proxmox-backup 6/9] fix #7908: datastore: ui: " Shan Shaji
2026-10-19 16:03 ` [PATCH proxmox-backup 7/9] fix #7908: backup-manager: " Shan Shaji
2026-10-19 16:03 ` [PATCH proxmox-backup 8/9] docs: add explanation regarding ``rebuild-chunk-markers`` option Shan Shaji
2026-10-19 16:03 ` [PATCH proxmox 9/9] proxmox-log: add LogThrottle implementation Shan Shaji

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261019160359.20851-2-s.shaji@proxmox.com \
    --to=s.shaji@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal