Skip to content

Commit 0eac642

Browse files
authored
Merge branch 'main' into feat/nwc-alby
2 parents 3779b7f + 214bef5 commit 0eac642

73 files changed

Lines changed: 2459 additions & 503 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nostream": patch
3+
---
4+
5+
Migrate runtime logging to pino across adapters, services, workers, and controllers, and stabilize CI-related fixes for coverage and integration workflows after rebasing.

.changeset/quick-maps-marry.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"nostream": minor
3+
---
4+
5+
Add gzip and xz compression support to event import/export flows.
6+
7+
- Export supports `--compress`/`-z` with `--format gzip|gz|xz`.
8+
- Import auto-detects compressed input by extension and magic bytes and decompresses in a stream pipeline.
9+
- Includes docs updates and unit/integration test coverage for compression paths.

.knip.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"project": [
99
"src/**/*.ts"
1010
],
11+
"ignoreDependencies": [
12+
"lzma-native"
13+
],
1114
"ignoreFiles": [],
1215
"commitlint": false,
1316
"eslint": false,

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,23 @@ Print the I2P hostname:
262262
263263
### Importing events from JSON Lines
264264
265-
You can import NIP-01 events from a `.jsonl` file directly into the relay database.
265+
You can import NIP-01 events from `.jsonl` files directly into the relay database.
266+
Compressed files are also supported and decompressed on-the-fly:
267+
268+
- `.jsonl.gz` (Gzip)
269+
- `.jsonl.xz` (XZ)
266270
267271
Basic import:
268272
```
269273
npm run import -- ./events.jsonl
270274
```
271275
276+
Import a compressed backup:
277+
```
278+
npm run import -- ./events.jsonl.gz
279+
npm run import -- ./events.jsonl.xz
280+
```
281+
272282
Set a custom batch size (default: `1000`):
273283
```
274284
npm run import -- ./events.jsonl --batch-size 500
@@ -652,16 +662,42 @@ To observe client and subscription counts in real-time during a test, you can in
652662
```bash
653663
docker compose logs -f nostream
654664
```
655-
656665
## Export Events
657666

658667
Export all stored events to a [JSON Lines](https://jsonlines.org/) (`.jsonl`) file. Each line is a valid NIP-01 Nostr event JSON object. The export streams rows from the database using cursors, so it works safely on relays with millions of events without loading them into memory.
659668

669+
Optional compression is supported for lower storage and transfer costs:
670+
671+
- Gzip via Node's native `zlib`
672+
- XZ via `lzma-native`
673+
660674
```
661675
npm run export # writes to events.jsonl
662676
npm run export -- backup-2024-01-01.jsonl # custom filename
677+
npm run export -- backup.jsonl.gz --compress --format=gzip
678+
npm run export -- backup.jsonl.xz --compress --format=xz
663679
```
664680

681+
Flags:
682+
683+
- `--compress` / `-z`: enable compression.
684+
- `--format <gzip|gz|xz>`: compression format. If omitted while compression is enabled,
685+
format is inferred from file extension (`.gz` / `.xz`) and defaults to `gzip`.
686+
687+
After completion, the exporter prints a summary with:
688+
689+
- Raw bytes generated from JSONL lines
690+
- Output bytes written to disk
691+
- Compression delta (smaller/larger)
692+
- Throughput in events/sec and bytes/sec
693+
694+
Optional XZ tuning (environment variables):
695+
696+
- `NOSTREAM_XZ_THREADS`: max worker threads for XZ compression.
697+
Defaults to `4` and is automatically capped to available CPU cores minus one.
698+
- `NOSTREAM_XZ_PRESET`: compression preset from `0` (fastest, larger output)
699+
to `9` (slowest, smallest output). Default is `6`.
700+
665701
The script reads the same `DB_*` environment variables used by the relay (see [CONFIGURATION.md](CONFIGURATION.md)).
666702

667703
## Benchmark Database Queries

biome.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,24 @@
2424
"recommended": false,
2525
"correctness": { "noUnusedVariables": "error" },
2626
"style": { "useBlockStatements": "warn" },
27-
"suspicious": { "noExplicitAny": "off" }
27+
"suspicious": {
28+
"noExplicitAny": "off",
29+
"noConsole": "error"
30+
}
2831
}
2932
},
33+
"overrides": [
34+
{
35+
"includes": ["migrations/**", "src/clean-db.ts", "src/import-events.ts", "src/scripts/**", "test/**"],
36+
"linter": {
37+
"rules": {
38+
"suspicious": {
39+
"noConsole": "off"
40+
}
41+
}
42+
}
43+
}
44+
],
3045
"javascript": {
3146
"formatter": {
3247
"quoteStyle": "single",

0 commit comments

Comments
 (0)