MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / claimQueue

Method claimQueue

src/telemetry/index.ts:509–523  ·  view source on GitHub ↗

* Atomically claim the queue for sending (rename). Concurrent processes * can't double-send; a crash mid-send leaves a claim file that * `recoverStaleClaims` merges back after an hour.

()

Source from the content-addressed store, hash-verified

507 * `recoverStaleClaims` merges back after an hour.
508 */
509 private claimQueue(): { claimPath: string; lines: BufferLine[] } | null {
510 const claimPath = path.join(this.dir, `telemetry-queue.sending.${process.pid}.jsonl`);
511 try {
512 fs.renameSync(this.queuePath, claimPath);
513 } catch {
514 return null; // no queue, or another process just claimed it
515 }
516 let lines: BufferLine[] = [];
517 try {
518 lines = parseLines(fs.readFileSync(claimPath, 'utf8'));
519 } catch {
520 /* unreadable claim — treat as empty; file removed by caller */
521 }
522 return { claimPath, lines };
523 }
524
525 private recoverStaleClaims(): void {
526 try {

Callers 1

flushNowMethod · 0.95

Calls 2

parseLinesFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected