Commit c110043
committed
feat: add time-based rotation to RotatingWriter (#136)
RotatingWriter now rotates segments based on wall-clock time in addition
to file size. Rotation triggers when *either* condition is met:
- File exceeds `max_file_size` bytes (existing behavior)
- A wall-clock-aligned time boundary is crossed (new)
The default rotation period is 60 seconds, aligned to round minute
boundaries (e.g. if the writer starts at 14:03:22, the first rotation
fires at 14:04:00). This is configurable via the builder:
RotatingWriter::builder()
.rotation_period(Duration::from_secs(300)) // every 5 min
Time-aligned segments produce clean S3 key paths when using the
`worker-s3` feature (keys already use `{YYYY-MM-DD}/{HHMM}` bucketing).
Edge cases:
- Time rotation is skipped when no real events have been written
(avoids empty sealed segments)
- `single_file()` disables time rotation (Duration::MAX)
- Eviction budget is respected with frequent time rotations
Closes #1361 parent 2117416 commit c110043
2 files changed
Lines changed: 354 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
| 54 | + | |
52 | 55 | | |
53 | 56 | | |
54 | 57 | | |
| |||
202 | 205 | | |
203 | 206 | | |
204 | 207 | | |
205 | | - | |
| 208 | + | |
206 | 209 | | |
207 | 210 | | |
208 | 211 | | |
| |||
0 commit comments