Files
usenet-indexer/lib/edge/wire.ts
T
Daan MeijerandClaude Opus 5.5 d5f168d8d2
Test and deploy / test (push) Successful in 21s
Test and deploy / deploy (push) Skipped
Rebuild: coordinator (planner, NNTP pool, spool, prefetcher, leases, rule sets), node API and the edge:node worker
- groups:add / ranges:plan / nodes:create / coordinator:run commands
- the node API: lease, the range's chunks as one framed stream from the
  spool, batches, heartbeat, finish, release (node guard, token per node)
- edge:node: needs COORDINATOR_URL and NODE_TOKEN only (placeholders for
  the rest), posts a batch every 10 chunks, gives its range back on SIGTERM
- releases are gathered per batch: 1.04 chunk rows per release at 10
  chunks per batch (1.35 when built per XOVER chunk)
- partitions are checked per batch instead of remembered

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 00:31:06 +02:00

24 lines
888 B
TypeScript

import type { EdgeBatch } from './range_indexer.js'
/** An EdgeBatch as JSON: chunk payloads in base64. */
export type WireBatch = Omit<EdgeBatch, 'releases' | 'samples'> & {
releases: (Omit<EdgeBatch['releases'][number], 'payload'> & { payload: string })[]
samples: (Omit<EdgeBatch['samples'][number], 'payload'> & { payload: string })[]
}
export function toWire(batch: EdgeBatch): WireBatch {
return {
...batch,
releases: batch.releases.map((r) => ({ ...r, payload: r.payload.toString('base64') })),
samples: batch.samples.map((s) => ({ ...s, payload: s.payload.toString('base64') })),
}
}
export function fromWire(wire: WireBatch): EdgeBatch {
return {
...wire,
releases: wire.releases.map((r) => ({ ...r, payload: Buffer.from(r.payload, 'base64') })),
samples: wire.samples.map((s) => ({ ...s, payload: Buffer.from(s.payload, 'base64') })),
}
}