CaptureShardModel
Defined in: packages/core/src/models/capture-shard.ts:20
Data operations for the stages of a sharded capture.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CaptureShardModel(
db,tables?):CaptureShardModel
Defined in: packages/core/src/models/capture-shard.ts:24
Parameters
Section titled “Parameters”tables?
Section titled “tables?”Returns
Section titled “Returns”CaptureShardModel
Methods
Section titled “Methods”claimFinalize()
Section titled “claimFinalize()”claimFinalize(
projectId,buildId,now?):Promise<boolean>
Defined in: packages/core/src/models/capture-shard.ts:149
Try to become the one worker that finalizes the build. The claim row’s primary key is
<buildId>:finalize, so inserting it succeeds for exactly one caller on every database;
everyone else gets a key conflict, which this reports as false.
A claim still running after FINALIZE_STALE_MS belonged to a worker that died
mid-finalize, and is taken over. Two late takers can both win; finalizing is idempotent.
Parameters
Section titled “Parameters”projectId
Section titled “projectId”string
buildId
Section titled “buildId”string
Date = ...
Returns
Section titled “Returns”Promise<boolean>
clearBuild()
Section titled “clearBuild()”clearBuild(
buildId):Promise<void>
Defined in: packages/core/src/models/capture-shard.ts:51
Forget every stage of a build: a new plan (retry, recovery) starts clean.
Parameters
Section titled “Parameters”buildId
Section titled “buildId”string
Returns
Section titled “Returns”Promise<void>
complete()
Section titled “complete()”complete(
id,result):Promise<void>
Defined in: packages/core/src/models/capture-shard.ts:100
Finish a shard with its outcome (JSON). Idempotent: a redelivered shard overwrites its own result.
Parameters
Section titled “Parameters”string
result
Section titled “result”string
Returns
Section titled “Returns”Promise<void>
createPlan()
Section titled “createPlan()”createPlan(
projectId,buildId,plan,shards):Promise<CaptureShard[]>
Defined in: packages/core/src/models/capture-shard.ts:64
Record a plan: the plan row (already done, it ran) and one pending render shard per slice.
Returns the render shards in ordinal order.
Parameters
Section titled “Parameters”projectId
Section titled “projectId”string
buildId
Section titled “buildId”string
attemptId
Section titled “attemptId”string | null
payload
Section titled “payload”string
result
Section titled “result”string
shards
Section titled “shards”NewRenderShard[]
Returns
Section titled “Returns”Promise<CaptureShard[]>
fail()
Section titled “fail()”fail(
id,error):Promise<void>
Defined in: packages/core/src/models/capture-shard.ts:124
The shard’s last try failed. Ignored for a shard already done, like retry.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”Promise<void>
finishFinalize()
Section titled “finishFinalize()”finishFinalize(
buildId):Promise<void>
Defined in: packages/core/src/models/capture-shard.ts:170
The finalize ran to the end: its claim is closed for good.
Parameters
Section titled “Parameters”buildId
Section titled “buildId”string
Returns
Section titled “Returns”Promise<void>
get(
id):Promise<CaptureShard|null>
Defined in: packages/core/src/models/capture-shard.ts:29
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<CaptureShard | null>
listForBuild()
Section titled “listForBuild()”listForBuild(
buildId):Promise<CaptureShard[]>
Defined in: packages/core/src/models/capture-shard.ts:34
Every row of a build, in plan, render, finalize and ordinal order.
Parameters
Section titled “Parameters”buildId
Section titled “buildId”string
Returns
Section titled “Returns”Promise<CaptureShard[]>
markRunning()
Section titled “markRunning()”markRunning(
id):Promise<void>
Defined in: packages/core/src/models/capture-shard.ts:94
Mark a shard running. A shard already done stays done: this run is a redelivered duplicate.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
plan()
Section titled “plan()”plan(
buildId):Promise<CaptureShard|null>
Defined in: packages/core/src/models/capture-shard.ts:46
Parameters
Section titled “Parameters”buildId
Section titled “buildId”string
Returns
Section titled “Returns”Promise<CaptureShard | null>
releaseFinalize()
Section titled “releaseFinalize()”releaseFinalize(
buildId):Promise<void>
Defined in: packages/core/src/models/capture-shard.ts:180
The finalize failed: drop its claim, so the next run to reduce the build can finalize it.
Parameters
Section titled “Parameters”buildId
Section titled “buildId”string
Returns
Section titled “Returns”Promise<void>
renderShards()
Section titled “renderShards()”renderShards(
buildId):Promise<CaptureShard[]>
Defined in: packages/core/src/models/capture-shard.ts:42
Parameters
Section titled “Parameters”buildId
Section titled “buildId”string
Returns
Section titled “Returns”Promise<CaptureShard[]>
retry()
Section titled “retry()”retry(
id,error):Promise<void>
Defined in: packages/core/src/models/capture-shard.ts:115
A failed run that will be retried: back to pending, remembering why. Ignored for a shard
already done, whose result a failing duplicate must not undo.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”Promise<void>