From 2e799fa7ec57d284c643df8b8dc54471470f5c59 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 21 Nov 2025 04:04:05 +0000 Subject: feat: add database backend configuration options Add environment variable configuration for database backend selection: - Added DatabaseBackend enum (memory, nostrdb, lmdb) in src/config.rs - Updated relay builder to use configured backend in src/nostr/builder.rs - Added NGIT_DATABASE_BACKEND to .env.example with documentation - Updated docs/reference/configuration.md with backend comparison table NostrDB and LMDB backends prepared for future implementation when nostr-relay-builder adds support. Currently defaults to in-memory database with warning logs when persistent backends are selected. --- docs/reference/configuration.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'docs/reference') diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index fc7bbe0..e2ec9aa 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -224,6 +224,47 @@ NGIT_RELAY_DATA_PATH=/mnt/ssd/relay-data --- +#### `NGIT_DATABASE_BACKEND` + +**Description:** Database backend type for storing Nostr events +**Type:** String (enum: memory, nostrdb, lmdb) +**Default:** `memory` +**Required:** No + +**Valid Values:** +- `memory` - In-memory database (default, fastest, no persistence) +- `nostrdb` - NostrDB backend (persistent, optimized for Nostr) [Not yet implemented] +- `lmdb` - LMDB backend (persistent, general purpose) [Not yet implemented] + +**Examples:** +```bash +# Development (default, no persistence) +NGIT_DATABASE_BACKEND=memory + +# Production with NostrDB (when implemented) +NGIT_DATABASE_BACKEND=nostrdb + +# Production with LMDB (when implemented) +NGIT_DATABASE_BACKEND=lmdb +``` + +**Comparison:** + +| Backend | Persistence | Performance | Use Case | +|---------|-------------|-------------|----------| +| memory | No | Fastest | Development, testing | +| nostrdb | Yes | High | Production (Nostr-optimized) | +| lmdb | Yes | High | Production (general purpose) | + +**Notes:** +- `memory` backend loses all data on restart +- NostrDB and LMDB backends will use `NGIT_RELAY_DATA_PATH` for storage +- NostrDB and LMDB are planned features, not yet available +- Default `memory` backend suitable for development and testing only +- Production deployments should use persistent backends when available + +--- + ### Logging Configuration #### `RUST_LOG` -- cgit v1.2.3