0xMiden / 0xMiden/note-transport-service

Add PostgreSQL backend support for production deployments

Offen
#111 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
3
Forks
10
Ø Merge
2 Std. 23 Min.
Gemergte PRs (30 T.)
4

Beschreibung

### What should be done?

Add PostgreSQL as a supported database backend for the note transport node, alongside the existing SQLite backend.

The node currently supports only SQLite (via Diesel), which ties the dataset to a single host's local disk. For production/mainnet deployments the service's core requirement is durable storage of unconsumed notes, and a single-writer file on one machine makes data durability dependent on that host staying alive: a node failure or a reschedule to another host means data loss or an outage. Additionally, the current default of --database-url :memory: makes it easy to run without any persistence at all.

With Postgres support, the node can run against a cluster with streaming replication and automatic failover, so losing a host no longer means losing data, and the service itself can run as stateless replicas.

### How should it be done?

- Implement a PostgreSQL DatabaseBackend alongside the existing SQLite one. The storage layer is already abstracted behind the DatabaseBackend trait, Diesel supports Postgres, and the schema is a single notes table plus migrations, so the surface area is small.
- Select the backend from the --database-url scheme (e.g. postgres://... vs a file path), keeping SQLite as-is for local development and testing.
- Port the two existing migrations to Postgres (Diesel handles per-backend migrations).

### When is this task done?

- The node runs against a Postgres database via --database-url postgres://... with all existing functionality (store/fetch by tags, cursor pagination, retention cleanup, stats).
- The existing test suite runs against both dbs.

### Additional context

Requested by Gateway.fm as part of mainnet hardening for transport layer deployments.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Schauen Sie sich das bestehende DatabaseBackend-Trait und die SQLite-Implementierung an, um die Speicherabstraktion zu verstehen. Das Schema ist eine einzelne Notizentabelle mit Migrationen. Beginnen Sie mit der Implementierung eines PostgreSQL-Backends, das über das Schema der --database-url (postgres://) ausgewählt wird. Portieren Sie die beiden vorhandenen Migrationen zu Postgres unter Verwendung der Diesel-Migrationsunterstützung pro Backend. Führen Sie die bestehende Testsuite gegen beide Datenbanken aus, um die Funktionalität zu überprüfen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
postgresql, rust
Bereich
backend, database
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
65/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.