pub struct RunPurger { /* private fields */ }Expand description
Periodic task that purges terminal runs exceeding the retention policy.
§Examples
use std::sync::Arc;
use std::time::Duration;
use ironflow_api::purger::RunPurger;
use ironflow_store::entities::PurgePolicy;
use ironflow_store::memory::InMemoryStore;
use ironflow_store::store::Store;
use tokio_util::sync::CancellationToken;
let store: Arc<dyn Store> = Arc::new(InMemoryStore::new());
let policy = PurgePolicy {
max_age_days: 90,
max_runs_per_workflow: 1000,
dry_run: false,
};
let purger = RunPurger::new(store, policy)
.interval(Duration::from_secs(3600));
tokio::spawn(purger.run(CancellationToken::new()));Implementations§
Source§impl RunPurger
impl RunPurger
Sourcepub fn new(store: Arc<dyn Store>, policy: PurgePolicy) -> Self
pub fn new(store: Arc<dyn Store>, policy: PurgePolicy) -> Self
Create a purger with the default interval and batch size.
Sourcepub fn with_blob_store(self, blob_store: Option<Arc<dyn BlobStore>>) -> Self
pub fn with_blob_store(self, blob_store: Option<Arc<dyn BlobStore>>) -> Self
Set the blob store for artifact deletion.
When None, artifact metadata is still removed but no blobs are deleted
(they either do not exist or become orphans).
Sourcepub fn batch_size(self, batch_size: u32) -> Self
pub fn batch_size(self, batch_size: u32) -> Self
Set how many runs a single tick processes.
Sourcepub async fn run(self, shutdown: CancellationToken)
pub async fn run(self, shutdown: CancellationToken)
Run the purge loop until shutdown is cancelled.
Auto Trait Implementations§
impl !RefUnwindSafe for RunPurger
impl !UnwindSafe for RunPurger
impl Freeze for RunPurger
impl Send for RunPurger
impl Sync for RunPurger
impl Unpin for RunPurger
impl UnsafeUnpin for RunPurger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more