Type Alias WriteDeclaration
kind?: "last-value";
maxBytes: number;
maxDelayMs?: number;
maxPending: number;
name: string;
path: string;
scope: "principal";
apply(
ctx: WriteContext,
key: string,
value: unknown,
expectedVersion: string,
): MaybePromise<WriteApplied>;
key(ctx: WriteContext, request: Request): MaybePromise<string>;
read(ctx: WriteContext, key: string): MaybePromise<WriteRead>;
}
Methods
apply
-
apply(
ctx: WriteContext,
key: string,
value: unknown,
expectedVersion: string,
): MaybePromise<WriteApplied>Writes
valuewhen the key is still atexpectedVersionand returns the new version, or returns{ conflict }when it has moved. The check and the write must be one atomic step in the site's own storage.Parameters
- ctx: WriteContext
- key: string
- value: unknown
- expectedVersion: string
Returns MaybePromise<WriteApplied>
key
-
the key this principal may write for this request; a device naming any other key is refused
Parameters
- ctx: WriteContext
- request: Request
Returns MaybePromise<string>
read
-
the key's version now, read when a flush that already applied is repeated
Parameters
- ctx: WriteContext
- key: string
Returns MaybePromise<WriteRead>
Properties
Optionalkind
the compaction; last-value is the only kind there is
max Bytes
the most bytes of one value's JSON body
Optionalmax Delay Ms
The longest a queued write of this class may wait before the worker flushes it. Unset keeps the flush at the next network moment, an explicit flush or a page hide. Set, the first queued write starts a deadline, and the flush at it sends every queued record: one request per key.
max Pending
the most queued keys of this class one partition holds on a device
name
path
the pattern of the principal route this write edits; createSpool refuses a public route
scope
principal only; a public write is refused
The declaration
defineWritetakes. Every write class is "the last value wins" for one key per principal, applied only when the version the device edited from is still current. There is no class for a comment, a cart, a payment, a counter, an inventory change or an audit record, andkindaccepts nothing butlast-value.