Skip to content

CaptureShardModel

Defined in: packages/core/src/models/capture-shard.ts:20

Data operations for the stages of a sharded capture.

new CaptureShardModel(db, tables?): CaptureShardModel

Defined in: packages/core/src/models/capture-shard.ts:24

DatabaseAdapter

CaptureShardTables

CaptureShardModel

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.

string

string

Date = ...

Promise<boolean>


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.

string

Promise<void>


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.

string

string

Promise<void>


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.

string

string

string | null

string

string

NewRenderShard[]

Promise<CaptureShard[]>


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.

string

string

Promise<void>


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.

string

Promise<void>


get(id): Promise<CaptureShard | null>

Defined in: packages/core/src/models/capture-shard.ts:29

string

Promise<CaptureShard | null>


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.

string

Promise<CaptureShard[]>


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.

string

Promise<void>


plan(buildId): Promise<CaptureShard | null>

Defined in: packages/core/src/models/capture-shard.ts:46

string

Promise<CaptureShard | null>


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.

string

Promise<void>


renderShards(buildId): Promise<CaptureShard[]>

Defined in: packages/core/src/models/capture-shard.ts:42

string

Promise<CaptureShard[]>


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.

string

string

Promise<void>