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 from_config(store: Arc<dyn Store>, config: &ServerConfig) -> Self
pub fn from_config(store: Arc<dyn Store>, config: &ServerConfig) -> Self
Create a purger from the server configuration.
Takes the purge policy (PURGE_MAX_AGE_DAYS, PURGE_MAX_RUNS_PER_WORKFLOW,
PURGE_DRY_RUN), the interval (PURGE_INTERVAL_SECS) and the retention of
Provider Account usage history and signals
(PROVIDER_ACCOUNT_USAGE_RETENTION_DAYS, SIGNAL_RETENTION_DAYS).
Chain RunPurger::with_blob_store to delete artifact blobs too.
§Examples
use std::sync::Arc;
use ironflow_api::config::{ConfigError, ServerConfig};
use ironflow_api::purger::RunPurger;
use ironflow_store::memory::InMemoryStore;
use tokio_util::sync::CancellationToken;
let config = ServerConfig::from_env()?;
let purger = RunPurger::from_config(Arc::new(InMemoryStore::new()), &config);
tokio::spawn(purger.run(CancellationToken::new()));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 fn usage_retention_days(self, days: u32) -> Self
pub fn usage_retention_days(self, days: u32) -> Self
Set how many days of Provider Account usage history to keep.
§Examples
use std::sync::Arc;
use ironflow_api::purger::RunPurger;
use ironflow_store::entities::PurgePolicy;
use ironflow_store::memory::InMemoryStore;
let policy = PurgePolicy { max_age_days: 90, max_runs_per_workflow: 1000, dry_run: false };
let purger = RunPurger::new(Arc::new(InMemoryStore::new()), policy).usage_retention_days(7);Sourcepub fn signal_retention_days(self, days: u32) -> Self
pub fn signal_retention_days(self, days: u32) -> Self
Set how many days received signals are kept.
A signal older than this can no longer resume a run that opens its wait step late.
§Examples
use std::sync::Arc;
use ironflow_api::purger::RunPurger;
use ironflow_store::entities::PurgePolicy;
use ironflow_store::memory::InMemoryStore;
let policy = PurgePolicy { max_age_days: 90, max_runs_per_workflow: 1000, dry_run: false };
let purger = RunPurger::new(Arc::new(InMemoryStore::new()), policy).signal_retention_days(3);Sourcepub async fn run(self, shutdown: CancellationToken)
pub async fn run(self, shutdown: CancellationToken)
Run the purge loop until shutdown is cancelled.