Skip to content

Persist quota usage to SQLite (config field usage_db is currently unused) #134

@rubenhensen

Description

@rubenhensen

The config schema accepts usage_db = "<path>" (see conf/config.dev.toml:13 and the deployed config rendered by postguard-ops in main.tf:423), but CryptifyConfig in src/config.rs doesn't parse the field and nothing in src/store.rs ever reads or writes it. Quota state lives only in Store.shared.state.usage: HashMap<String, VecDeque<UploadRecord>> (src/store.rs:97), so any pod restart or redeploy wipes everyone's rolling quota — and there's no way to inspect or reset usage for a single user without a code change.

We should back the usage map with SQLite at the path given by usage_db:

  • Parse usage_db in RawCryptifyConfig / CryptifyConfig.
  • On startup, open the DB and load existing records into the in-memory map (or query on demand).
  • On record_upload / prune_records, write through to SQLite.
  • Mount a PVC for cryptify_data_dir in the dev/prod Kubernetes deployments so the file survives pod restarts (currently /tmp/data, no volume).

Nice-to-have once persisted: a small admin endpoint to reset quota for a single email, which today requires restarting the whole pod.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestrustPull requests that update Rust code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions