Arcana::Events::FileBackend
Inherits Arcana::Events::Backend < Reference < Object
Writes events as JSONL to a directory, one file per day.
Files:
<dir>/arcana-events-YYYY-MM-DD.jsonl (today, uncompressed) <dir>/arcana-events-YYYY-MM-DD.jsonl.gz (older days, compressed)The record call is non-blocking: events go onto a buffered
channel, drained by a background fiber that appends to the daily
file. If the channel fills up, events are dropped and the drop
count is logged to STDERR. (Better to drop than to block every
Bus.send on disk I/O.)
Retention (via sweep!):
- Files older than
compress_age_daysare gzipped and the uncompressed source is deleted. - Files (.jsonl or .jsonl.gz) older than
retain_daysare either deleted or moved toarchive_dir(if set). - If
max_size_mbis set and total dir size exceeds it, the oldest files are removed first until under the cap.
Constants
FILENAME_REGEX = /\Aarcana-events-(\d{4}-\d{2}-\d{2})\.jsonl(?:\.gz)?\z/
Constructors
Instance methods
archive_dir
Sourcecompress_age_days
Sourcedropped
Sourcelog_dir
Sourcemax_size_mb
Sourcequery(since : Time | Nil = nil, type : String | Nil = nil, subject : String | Nil = nil, limit : Int32 = 100) : Array(Event)
Query stored events. Filters are AND-combined.
record(event : Event) : Nil
Record an event. Should not block on I/O — implementations may queue asynchronously and return immediately.
retain_days
Sourcesweep!
Retention sweep — compresses old files and purges/archives very old ones. Safe to call periodically from any fiber.