/** * ╔══════════════════════════════════════════════════════════════════════╗ * ║ EXP-30 BAKE-OFF CANDIDATE B — object-per-batch + sidecar lease. ║ * ╚══════════════════════════════════════════════════════════════════════╝ * * A segment is a set of IMMUTABLE part objects keyed by byte offset: * `/parts/.jsonl` * * `appendBlock` writes the next part with `If-None-Match: *` at key = the * expected byte offset — so create-once is the position-check AND the fence in a * single PUT, with NO whole-object rewrite (the O(segment) cost that sinks * Candidate A at large segment sizes). A deposed leader racing for the same * offset key loses with 412. * * The lease lives in a SEPARATE sidecar object `/.lease`, CAS'd on its own * ETag. Because parts are immutable new keys, lease renewal never contends with * appends — the structural problem that forced Candidate A into A′ does not * exist here. * * READ MODEL: `segmentLength`/`readSegment` list the parts prefix and stitch in * offset order. This list+stitch is the cost Candidate B trades for cheap * appends; the broker consumer reads append segments through these. * * Note on design constraint #5 (lease on the data blob, never a separate * `.lock`): that rule is about Azure, where a lease only fences the *leased* * blob. Here the data-write fence is the per-part `If-None-Match` create-once — * which IS on the data — so the sidecar `.lease` is leadership coordination, not * the data fence. The spirit of #5 (data writes fenced at the data) holds. */ import { type AppendBlockOptions, type AppendResult, type LeaseToken, type RangeReadResult } from '../../types.js'; import { type S3StrategyContext } from '../s3Common.js'; import type { S3AppendLeaseStrategy, S3AppendStrategyName, S3CompactionResult } from './types.js'; /** Width of the zero-padded byte-offset in a part key (lexicographic == numeric sort). */ export declare const OFFSET_PAD = 20; /** Prefix under which a segment's immutable part objects live. Shared with Candidate D. */ export declare const partsPrefix: (path: string) => string; /** Deterministic key for the part starting at byte `offset`. Shared with Candidate D. */ export declare const partKey: (path: string, offset: number) => string; /** Recover the start byte-offset encoded in a part key. Shared with Candidate D. */ export declare const offsetFromKey: (key: string) => number; /** A part object: its start offset (from the key) and byte length. */ export type PartInfo = { Key: string; Offset: number; Size: number; }; export declare class ObjectPerBatchStrategy implements S3AppendLeaseStrategy { readonly name: S3AppendStrategyName; protected readonly client: S3StrategyContext['client']; protected readonly bucket: string; constructor(ctx: S3StrategyContext); createAppendBlob(path: string): Promise; /** * Idempotent create-once of the `.lease` sidecar. Shared by `createAppendBlob` * and `acquireLease` (ADR-0027): a leasable path must be leasable regardless of * which provider method created its data object. The consumer's offset blob is * made by the mechanical `putBlockBlob`, which never touches the sidecar, so * `acquireLease` provisions it here rather than 404ing on the missing sidecar. */ protected ensureLeaseObject(path: string): Promise; acquireLease(path: string, ttlSeconds: number): Promise; renewLease(path: string, lease: LeaseToken): Promise; releaseLease(path: string, lease: LeaseToken): Promise; /** * Throw {@link LeaseLostError} unless `lease` is the live holder of `path`'s * sidecar. The shared fence (ADR-0027) for the producer append hot path AND the * consumer offset-blob overwrite — both must reject a deposed holder. */ verifyLeaseHeld(path: string, lease: LeaseToken): Promise; appendBlock(path: string, bytes: Buffer, options: AppendBlockOptions): Promise; segmentLength(path: string): Promise; readSegment(path: string): Promise; rangeReadSegment(path: string, start: number, end: number): Promise; compactSegment(srcPath: string, dstPath: string): Promise; /** GET a single object's full bytes. Protected so Candidate D reuses it. */ protected getObjectBytes(key: string): Promise; /** List part objects sorted by offset (zero-padded keys sort numerically). Paginated. */ protected listParts(path: string): Promise; } /** * Assemble the byte window `[start, end]` (inclusive) from a sorted, contiguous * list of part objects. Parts are contiguous (`part[i].Offset + part[i].Size == * part[i+1].Offset`), so the overlapping run forms one contiguous buffer that we * slice to the exact window. Shared by Candidate B and Candidate D's tail read. */ export declare function assemblePartWindow(getBytes: (key: string) => Promise, parts: PartInfo[], start: number, end: number): Promise; /** * GET the given parts with bounded concurrency, returning their bytes in the * SAME order as `parts` (order is load-bearing — the buffers are concatenated * into the byte stream). Shared by Candidate B and Candidate D's tail reads. */ export declare function getPartsConcurrent(getBytes: (key: string) => Promise, parts: PartInfo[]): Promise; //# sourceMappingURL=objectPerBatch.d.ts.map