1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! Backend-agnostic retention (TTL) configuration.
//!
//! Drives age-based cleanup of expired events and tasks across every
//! storage backend. A non-zero TTL makes [`super::A2aEventStore::cleanup_expired`]
//! delete rows older than the configured window; `0` disables expiry for
//! that row class.
//!
//! Age-based expiry is state-independent: a task past `task_ttl_seconds`
//! is reaped regardless of its `TaskState`. Setting a non-zero task TTL
//! can therefore reap long-running live tasks — choose a window larger
//! than the longest expected task lifetime, or leave it `0`.
//!
//! Cleanup deletes in bounded batches of `cleanup_batch_size` rows,
//! committing each batch, so a large backlog does not hold one
//! long-running transaction (SQL) or the write lock for the whole sweep
//! (in-memory). A single `cleanup_expired` call still drains everything
//! eligible; it just does so incrementally.
/// Default number of rows deleted per committed cleanup batch.
pub const DEFAULT_CLEANUP_BATCH_SIZE: usize = 1000;
/// TTL window for expired events and tasks, plus the cleanup batch size.
///
/// `0` for either TTL means "no expiry" for that row class — the default
/// for SQL and in-memory backends. DynamoDB does not use this type; it
/// reaps via engine-native TTL configured on its own `DynamoDbConfig`.
///
/// Construct with [`RetentionConfig::new`] and refine the batch size with
/// [`RetentionConfig::with_batch_size`]; the struct is `non_exhaustive`
/// so future knobs can be added without breaking call sites.