- seed:plan plans every part of a group's history no range covers (it started below the lowest known range and left a.b.ath's 13 most recent months out); seed_ranges.priority orders leases (seed:plan --priority). - binaries.part_count, kept by the parts insert in the same statement: claimCompleted compares it instead of counting parts every batch. - file_keys: 64-bit hashes of all file keys; FileStore.insert asks it before probing every files partition. - worker:file stores 100 completed binaries per job with set-based queries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
import { BaseCommand, args, flags } from '@adonisjs/core/ace'
|
||
import { CommandOptions } from '@adonisjs/core/types/ace'
|
||
import NntpService from '#services/NntpService'
|
||
import SeedOrchestrator from '#services/SeedOrchestrator'
|
||
|
||
/**
|
||
* Plans seed ranges (CONCEPT.md D38) for groups: every article from below
|
||
* what live indexing and the backfill cover down to `--days` back (or the
|
||
* server's oldest article) that no earlier range covers. Running it again
|
||
* plans only what's missing. A group's backfill stops where its plan
|
||
* starts. Ranges are interleaved across groups, newest first.
|
||
*
|
||
* node ace seed:plan alt.binaries.ath alt.binaries.mom --days 365
|
||
*/
|
||
export default class SeedPlan extends BaseCommand {
|
||
public static commandName = 'seed:plan'
|
||
public static description = 'Plans article ranges of groups for seeding nodes to lease.'
|
||
|
||
public static options: CommandOptions = {
|
||
startApp: true,
|
||
}
|
||
|
||
@args.spread({ description: 'Groups' })
|
||
declare groups: string[]
|
||
|
||
@flags.number({ description: 'How many days back (default: everything the server has)' })
|
||
declare days?: number
|
||
|
||
@flags.number({ description: 'Articles per range', default: 2_000_000 })
|
||
declare size: number
|
||
|
||
@flags.number({ description: 'Leased before ranges of a lower priority (default 0)', default: 0 })
|
||
declare priority: number
|
||
|
||
public async run() {
|
||
try {
|
||
const summary = await SeedOrchestrator.plan(this.groups, { days: this.days, size: this.size, priority: this.priority })
|
||
for (const s of summary) {
|
||
this.logger.info(
|
||
`${s.group}: ${s.ranges.toLocaleString('en')} new ranges in ${s.gaps} gap(s) not yet planned, articles ${s.from.toLocaleString('en')}–${s.to.toLocaleString('en')}.`
|
||
)
|
||
}
|
||
} finally {
|
||
await NntpService.shutdown()
|
||
}
|
||
}
|
||
}
|