durability 4.1.2 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +204 -0
- package/dist/durable-object-target.d.ts +12 -0
- package/dist/durable-object-target.js +17 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +14 -0
- package/dist/experimental.d.ts +3 -0
- package/dist/experimental.js +3 -0
- package/dist/lifecycle.d.ts +14 -3
- package/dist/migrations.d.ts +28 -1
- package/dist/migrations.js +175 -0
- package/dist/outbox.d.ts +72 -0
- package/dist/outbox.js +385 -0
- package/dist/routing.d.ts +2 -9
- package/dist/routing.js +2 -14
- package/dist/scheduler.d.ts +7 -2
- package/dist/scheduler.js +12 -6
- package/dist/semaphore-client.d.ts +22 -0
- package/dist/semaphore-client.js +61 -0
- package/dist/semaphore-leases.d.ts +109 -0
- package/dist/semaphore-leases.js +266 -0
- package/dist/semaphore-protocol.d.ts +231 -0
- package/dist/semaphore-protocol.js +106 -0
- package/dist/semaphore-queue-store.d.ts +85 -0
- package/dist/semaphore-queue-store.js +221 -0
- package/dist/semaphore-queue.d.ts +119 -0
- package/dist/semaphore-queue.js +797 -0
- package/dist/semaphore-server.d.ts +89 -0
- package/dist/semaphore-server.js +520 -0
- package/dist/semaphore-store.d.ts +43 -0
- package/dist/semaphore-store.js +108 -0
- package/dist/semaphore.d.ts +42 -0
- package/dist/semaphore.js +57 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@ Composable capabilities for application-owned Cloudflare Durable Objects:
|
|
|
5
5
|
- **`Durability`** — effectively-once operations with retries, idempotency, and result lookup.
|
|
6
6
|
- **`DurabilityAlarms`** — named logical alarms with retries and stable idempotency keys.
|
|
7
7
|
- **`DurabilityFanout`** — durable batch acceptance and independent delivery to static consumer or storage targets.
|
|
8
|
+
- **`DurabilityOutbox`** _(experimental, `durability/experimental`)_ — keyed latest-state publication: stage the newest value for a key with the state it describes, and it is republished until acknowledged.
|
|
9
|
+
- **`DurabilitySemaphore`** _(experimental, `durability/experimental/semaphore`)_ — one concurrency limit shared by many client Durable Objects, allocated in arrival-ordered rounds with cumulative claim/release accounting.
|
|
8
10
|
- **`DurabilityRouting`** — a DO-side load observer and client-side shard selector (`durability/routing`), supporting location hints and caller transforms.
|
|
9
11
|
- **`DurabilitySocket`** — typed WebSocket RPC and replayable event push from a Durable Object to browsers (`durability/socket`), with a dependency-free browser client (`durability/client`).
|
|
10
12
|
- **`DurabilityTracker`** _(experimental, `durability/experimental`)_ — lists work across capabilities and custom sources, as RPC handles that can be waited on or as plain records.
|
|
@@ -511,6 +513,149 @@ new DurabilityTracker({ sources: { jobs: this.durability, approvals } });
|
|
|
511
513
|
|
|
512
514
|
New members of `TrackedSource` are always optional, so a custom source keeps compiling across releases.
|
|
513
515
|
|
|
516
|
+
## Semaphore (experimental)
|
|
517
|
+
|
|
518
|
+
Everything under `durability/experimental/semaphore` may change or be removed in a minor release; pin an exact version when depending on it. It is a separate entry point from `durability/experimental` because its client resolves Durable Object namespaces through `cloudflare:workers`.
|
|
519
|
+
|
|
520
|
+
`DurabilitySemaphore` holds one concurrency limit — say, an account's maximum running jobs — inside an application-owned Durable Object, and hands permits to many client Durable Objects that queue work. Requests arriving within a round are allocated together in arrival order, so the oldest queued work across all clients is admitted first. Groups (a workflow, a tenant) may carry their own ceiling under the shared limit.
|
|
521
|
+
|
|
522
|
+
```ts
|
|
523
|
+
import { DurableObject } from 'cloudflare:workers';
|
|
524
|
+
import { timeout } from '@durability/transforms';
|
|
525
|
+
import { DurabilityScheduler } from 'durability';
|
|
526
|
+
import {
|
|
527
|
+
DurabilitySemaphore,
|
|
528
|
+
type SemaphoreRequest,
|
|
529
|
+
} from 'durability/experimental/semaphore';
|
|
530
|
+
|
|
531
|
+
/** One instance per account; the account id is the semaphore key. */
|
|
532
|
+
export class AccountLimit extends DurableObject<Env> {
|
|
533
|
+
private readonly scheduler = new DurabilityScheduler({ context: this.ctx });
|
|
534
|
+
private readonly semaphore = new DurabilitySemaphore({
|
|
535
|
+
scheduler: this.scheduler,
|
|
536
|
+
limit: () => this.env.ACCOUNT_CONCURRENCY,
|
|
537
|
+
groupLimit: (workflowId) => this.workflowLimits.get(workflowId),
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
permits(message: SemaphoreRequest) {
|
|
541
|
+
return this.semaphore.handle(message);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
override alarm(info?: AlarmInvocationInfo) {
|
|
545
|
+
return this.scheduler.alarm(info);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
export const limits = DurabilitySemaphore.client({
|
|
550
|
+
target: AccountLimit, // Vite injects exportName
|
|
551
|
+
invoke: (stub, message) => stub.permits(message),
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
// From a client Durable Object:
|
|
555
|
+
const grant = await limits.with(timeout, 5_000).request(accountId, {
|
|
556
|
+
type: 'request',
|
|
557
|
+
v: 1,
|
|
558
|
+
clientId: this.ctx.id.toString(),
|
|
559
|
+
demand: [{ group: workflowId, count: queued, oldestAt: oldestEnqueuedAt }],
|
|
560
|
+
grants: [{ grantId, claimed: 3, released: 1 }], // cumulative reports
|
|
561
|
+
});
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
- **Rounds.** `handle()` holds a request for up to `roundWaitMs` (default 1 second) so concurrent requests are allocated together, and runs rounds no closer than `roundPeriodMs` (default 2 seconds). The response's `nextRequestAt` tells the client when it may ask again.
|
|
565
|
+
- **Grants and reports.** Each `(client, group)` that receives permits gets a grant. Clients report `claimed` (permits actually used) and `released` (claimed permits returned) per grant as cumulative high-water marks, piggybacked on requests or sent with a `sync` message. Counts only move forward and are clamped to the grant, so lost, repeated, or reordered reports can never free capacity twice. Permits a client never claims within `grantTimeoutMs` (default 10 seconds) are reclaimed; a later claim is answered with the clamped count and `status: 'expired'`.
|
|
566
|
+
- **Blocked attribution.** Demand that stays queued is explained per group: `group_limit`, `limit`, `not_permitted` (`canGrant` returned false), or `limit_resolution_error` (`groupLimit` threw; the group fails closed).
|
|
567
|
+
- **Limits are live.** `limit` and `groupLimit` are resolved once per round. Lowering a limit never evicts running work; it stops new admissions until usage is below the new ceiling.
|
|
568
|
+
- **Client side.** `DurabilitySemaphore.client()` has the same shape as `DurabilityRouting.client()`: the Vite plugin injects `exportName`, `namespace` is the escape hatch, and caller transforms such as `timeout` compose. The underlying `SemaphoreClient` is transport-independent and remembers each key's `nextRequestAt`.
|
|
569
|
+
|
|
570
|
+
`usage()` reports the limit, outstanding permits, lease footprint, and per-group usage. `DurabilitySemaphore.migrate(this.ctx, null)` removes the schema.
|
|
571
|
+
|
|
572
|
+
### Leases
|
|
573
|
+
|
|
574
|
+
Rounds cost a round trip per batch of admissions. For bursty arrivals, the holder can hand each `(client, group)` with queued demand a **lease**: a block of permits the client may draw locally, one per item, with no round trip. Where that capacity comes from is the `provisioning` mode:
|
|
575
|
+
|
|
576
|
+
```ts
|
|
577
|
+
new DurabilitySemaphore({
|
|
578
|
+
scheduler,
|
|
579
|
+
limit: 100,
|
|
580
|
+
leases: {
|
|
581
|
+
provisioning: { mode: 'strict' }, // leases share the limit with grants
|
|
582
|
+
// provisioning: { mode: 'under', reserve: 20 }, // 20 of the 100 kept for leases; grants get 80
|
|
583
|
+
// provisioning: { mode: 'over', extra: { ratio: 0.5 } }, // 50 more above the limit, for leases only
|
|
584
|
+
permitsPerLease: 64,
|
|
585
|
+
ttlMs: 30 * 60_000,
|
|
586
|
+
},
|
|
587
|
+
});
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
- **`strict`** — "always below": grants are allocated first, then leases from whatever is left; a live lease's footprint (permits not yet released) is reserved from the same pool. Total never exceeds the limit.
|
|
591
|
+
- **`under`** — a reserve inside the limit is kept for leases; grants may use at most `limit - reserve`. Still never exceeds the limit, and leases have guaranteed headroom. The reserve never takes the last permit: with a reserve at or above the limit (including after lowering the limit), grants keep one, so groups excluded from leases and clients without lease support still make progress.
|
|
592
|
+
- **`over`** — leases come from a separate budget above the limit (the original gatekeeper behaviour); the effective ceiling is `limit + extra`.
|
|
593
|
+
|
|
594
|
+
Leases are issued only to clients that report `leases` (the queue always does), to groups without their own limit unless `limitedGroups: 'withinGroupLimit'`, and only to a client that holds no undrawn permits for that group. Each round shares the remaining lease budget equally among candidates, oldest demand first, up to `permitsPerLease`; with fewer permits left than candidates, the oldest get one each. When a round leaves demand unserved, the holder marks its replies `contended`, and each client returns the undrawn permits of leases in groups where it has nothing queued, so an idle lease cannot keep other clients waiting. A client that stops talking to the holder keeps its lease until `ttlMs`. Reports (`drawn`, `released` high-water marks) heartbeat a lease; one unreported for `ttlMs` is swept, and a report for a lease the holder no longer knows is answered retired and its live footprint charged against that round. On the client, a drawn permit is one-shot: releasing the item returns footprint to the holder but never makes the permit drawable again. Lowering a group's eligibility, or the limit, retires leases on the next round. A retired lease stops drawing at once but stays counted in full until its client confirms how much it drew, since it may have drawn after its last report.
|
|
595
|
+
|
|
596
|
+
### Queueing work in a client Durable Object
|
|
597
|
+
|
|
598
|
+
`DurabilitySemaphoreQueue` is the client half: it queues items per semaphore key in arrival order, drives the protocol above against the holder, and hands items to the application once a permit is confirmed. Claims and releases are published through an internal `DurabilityOutbox` channel as cumulative counts, so a crash or lost response never loses or double-counts a permit.
|
|
599
|
+
|
|
600
|
+
```ts
|
|
601
|
+
import { DurableObject } from 'cloudflare:workers';
|
|
602
|
+
import { timeout } from '@durability/transforms';
|
|
603
|
+
import { Durability, DurabilityScheduler } from 'durability';
|
|
604
|
+
import { DurabilitySemaphoreQueue } from 'durability/experimental/semaphore';
|
|
605
|
+
|
|
606
|
+
/** Many shards, each queueing jobs for many accounts. */
|
|
607
|
+
export class JobShard extends DurableObject<Env> {
|
|
608
|
+
private readonly scheduler = new DurabilityScheduler({ context: this.ctx });
|
|
609
|
+
private readonly jobs = new Durability({
|
|
610
|
+
scheduler: this.scheduler,
|
|
611
|
+
handlers: { run: (job: Job) => runJob(this.env, job) },
|
|
612
|
+
// Return the permit as soon as the operation reaches a terminal state.
|
|
613
|
+
onLifecycleEvent: (event) => {
|
|
614
|
+
if (
|
|
615
|
+
event.type === 'terminal' ||
|
|
616
|
+
(event.type === 'attempt_settled' && event.outcome === 'completed')
|
|
617
|
+
) {
|
|
618
|
+
return this.permits.release(event.id).then(() => undefined);
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
});
|
|
622
|
+
private readonly permits = new DurabilitySemaphoreQueue<Job>({
|
|
623
|
+
scheduler: this.scheduler,
|
|
624
|
+
clientId: this.ctx.id.toString(),
|
|
625
|
+
server: limits.with(timeout, 5_000),
|
|
626
|
+
admit: (items) =>
|
|
627
|
+
Promise.all(
|
|
628
|
+
items.map((item) => this.jobs.run({ id: item.id, payload: item.body }))
|
|
629
|
+
),
|
|
630
|
+
// The hook above is best-effort; this check returns any permit it missed.
|
|
631
|
+
finished: async (ids) => {
|
|
632
|
+
const results = await Promise.all(
|
|
633
|
+
ids.map((id) => this.jobs.run.getResult(id))
|
|
634
|
+
);
|
|
635
|
+
return ids.filter((_, index) => results[index]!.status !== 'pending');
|
|
636
|
+
},
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
submit(job: Job) {
|
|
640
|
+
return this.permits.enqueue([
|
|
641
|
+
{ id: job.id, key: job.accountId, group: job.workflowId, body: job },
|
|
642
|
+
]);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
override alarm(info?: AlarmInvocationInfo) {
|
|
646
|
+
return this.scheduler.alarm(info);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
- **States.** An item is `queued` until permits arrive, `claiming` while the holder confirms the claim, and `admitted` once `admit()` has been handed the item. Items drawn from a lease skip `claiming` and are admitted at once; `AdmittedItem.via` says which path admitted an item. `admit()` runs after the admission commits and is retried under `retries.delay` until it returns, so it must be idempotent on item ID. `release(id)` returns the permit; `cancel(id)` removes an item that is still `queued`.
|
|
652
|
+
- **Releasing.** Call `release(id)` when the work ends, and pass `finished(ids)` so a release that never happens — a lifecycle hook is best-effort, a crash can come between the work ending and the call — does not hold the permit forever. The queue asks `finished` about each admitted item `finishedCheckMs` (default 60 seconds) after `admit()` returned, and again at that interval, releasing the ones it reports done. Without `finished`, a lost `release()` leaks the permit until the item is released by hand.
|
|
653
|
+
- **Requests.** Each key is asked at most once per `nextRequestAt`, with demand aggregated per group from the oldest queued items. A failed request, or one unanswered after `attemptTimeoutMs`, is retried with backoff. Items whose key already holds unclaimed permits — a grant sized for demand that was cancelled, say — are admitted without a request.
|
|
654
|
+
- **Blocked attribution.** `status(id)` on a queued item carries the holder's most recent reason for that key and group (`limit`, `group_limit`, …); `blocked` lifecycle events report counts per group. Attribution is in-memory and best-effort.
|
|
655
|
+
- **Composition.** The queue shares the scheduler with everything else in the object and creates its own outbox channel (`durability.semaphore-queue`) on it; one queue per scheduler. Pass `DurabilitySemaphore.client()` as `server` — caller transforms apply to every request and sync.
|
|
656
|
+
|
|
657
|
+
`DurabilitySemaphoreQueue.migrate(this.ctx, null)` removes the queue schema. See the typechecked [account concurrency composition](../../examples/account-concurrency).
|
|
658
|
+
|
|
514
659
|
## Routing and fanout
|
|
515
660
|
|
|
516
661
|
A queue is a composition, not another exported abstraction. An application owns its DO class and attaches the capabilities it needs:
|
|
@@ -672,6 +817,65 @@ Routing uses the actual `@durability/transforms` runtime. For example, `routing.
|
|
|
672
817
|
|
|
673
818
|
Loopback namespaces need the application DO declared in Wrangler migrations (or the platform's supported class configuration), but no redundant DO binding block is needed. Consumer transport is explicitly wired by the application, such as a service binding or loopback entrypoint. See the typechecked [email queue composition](../../examples/email-queue).
|
|
674
819
|
|
|
820
|
+
## Outbox (experimental)
|
|
821
|
+
|
|
822
|
+
`DurabilityOutbox` is exported from `durability/experimental` and may change in a minor release; pin an exact version when depending on it.
|
|
823
|
+
|
|
824
|
+
`DurabilityOutbox` publishes the newest state of a key to something outside the object — a KV namespace, another Durable Object, an API — and keeps retrying until the sink accepts it. Use it when consumers need the latest value, not every change: restaging a key before it is published replaces the pending version, so superseded versions may never be sent. For message delivery where every message matters, use `DurabilityFanout`.
|
|
825
|
+
|
|
826
|
+
```ts
|
|
827
|
+
import { DurableObject } from 'cloudflare:workers';
|
|
828
|
+
import { DurabilityScheduler } from 'durability';
|
|
829
|
+
import { DurabilityOutbox } from 'durability/experimental';
|
|
830
|
+
|
|
831
|
+
type Topology = { workflowId: string; steps: string[] };
|
|
832
|
+
|
|
833
|
+
export class Account extends DurableObject<Env> {
|
|
834
|
+
private readonly scheduler = new DurabilityScheduler({ context: this.ctx });
|
|
835
|
+
private readonly topology = new DurabilityOutbox<Topology>({
|
|
836
|
+
scheduler: this.scheduler,
|
|
837
|
+
channel: 'topology',
|
|
838
|
+
// The sink keeps the highest version it has seen per key, so a slow
|
|
839
|
+
// publication of an older version can never overwrite a newer one.
|
|
840
|
+
publish: async (entries) => {
|
|
841
|
+
const results = await this.env.TOPOLOGY_INDEX.replace(
|
|
842
|
+
entries.map(({ key, version, value }) => ({ key, version, value }))
|
|
843
|
+
);
|
|
844
|
+
// Returning acknowledges every entry not marked for retry.
|
|
845
|
+
for (const [index, result] of results.entries()) {
|
|
846
|
+
if (!result.ok) {
|
|
847
|
+
entries[index]!.retry();
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
},
|
|
851
|
+
});
|
|
852
|
+
|
|
853
|
+
async saveTopology(topology: Topology) {
|
|
854
|
+
await this.ctx.storage.transaction(async () => {
|
|
855
|
+
this.ctx.storage.sql.exec(
|
|
856
|
+
'INSERT OR REPLACE INTO topologies (id, body) VALUES (?, ?)',
|
|
857
|
+
topology.workflowId,
|
|
858
|
+
JSON.stringify(topology)
|
|
859
|
+
);
|
|
860
|
+
await this.topology.stage(topology.workflowId, topology);
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
override alarm(info?: AlarmInvocationInfo) {
|
|
865
|
+
return this.scheduler.alarm(info);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
- **Atomic with application state.** `stage()` inside `ctx.storage.transaction()` commits or rolls back with the application's writes.
|
|
871
|
+
- **Versions.** Every `stage()` returns a version that is monotonic across the whole object, including after acknowledged entries are deleted. Sinks must be idempotent on `(key, version)` and keep the highest version they have seen: a slow publication of an older version can land after a newer one. A plain `KV.put` cannot do this; compare versions in a Durable Object, a transactional store, or a conditional write.
|
|
872
|
+
- **Acknowledgement.** `publish` returning acknowledges every entry not marked with `entry.retry(delayMs?)`; throwing or exceeding `attemptTimeoutMs` (default 60 seconds) retries the whole batch. Acknowledging a version deletes the entry only if it is still the newest, so an in-flight publication can never discard a later stage.
|
|
873
|
+
- **Retries never give up.** Dropping the newest state would leave the sink stale forever, so there is no attempt limit or dead-letter queue; `retries.delay(attempt)` controls backoff (default: jittered exponential capped at 5 minutes).
|
|
874
|
+
- **Channels.** Several outboxes share one scheduler and one set of tables, partitioned by `channel` (default `default`); each owns its own `publish`, and the same key in different channels is independent. Attaching two outboxes with the same channel to one scheduler throws. Entries of a channel no outbox attaches are retained and postponed, as fanout does for a removed target.
|
|
875
|
+
- **Batching.** `maxBatchSize` (default 50) bounds one `publish` call. `batchDelayMs` rounds first publication up to the next multiple of the delay, so stages within one window coalesce into a batch; a stage landing exactly on a boundary is due immediately.
|
|
876
|
+
|
|
877
|
+
`DurabilityOutbox.migrate(this.ctx, null)` removes the outbox schema.
|
|
878
|
+
|
|
675
879
|
## Retained log
|
|
676
880
|
|
|
677
881
|
Fanout deletes a record once every target settles it, which is what a work queue wants. A log wants the opposite: records are **retained** so a consumer can rewind, a new consumer can start from the beginning, and several consumers can read the same history at different speeds. `DurabilityLog` is that second shape, and it attaches to the same scheduler.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** An application-owned Durable Object class a client-side helper routes to. */
|
|
2
|
+
export type DurableObjectTarget<Target extends Rpc.DurableObjectBranded> = {
|
|
3
|
+
/** Application-owned exported Durable Object class. */
|
|
4
|
+
target: {
|
|
5
|
+
prototype: Target;
|
|
6
|
+
};
|
|
7
|
+
/** Injected by the Vite plugin; explicit for builds without it. */
|
|
8
|
+
exportName?: string;
|
|
9
|
+
/** Explicit namespace escape hatch for cross-worker or non-Vite consumers. */
|
|
10
|
+
namespace?: () => DurableObjectNamespace<Target>;
|
|
11
|
+
};
|
|
12
|
+
export declare const resolveNamespace: <Target extends Rpc.DurableObjectBranded>(config: DurableObjectTarget<Target>, error: (message: string) => Error) => DurableObjectNamespace<Target>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { exports as workerExports } from 'cloudflare:workers';
|
|
2
|
+
export const resolveNamespace = (config, error) => {
|
|
3
|
+
const namespace = config.namespace?.();
|
|
4
|
+
if (namespace) {
|
|
5
|
+
return namespace;
|
|
6
|
+
}
|
|
7
|
+
if (!config.exportName) {
|
|
8
|
+
throw error('Use the durability Vite plugin, exportName, or an explicit namespace to resolve the target');
|
|
9
|
+
}
|
|
10
|
+
const exported = Reflect.get(workerExports, config.exportName);
|
|
11
|
+
if (exported === null ||
|
|
12
|
+
(typeof exported !== 'object' && typeof exported !== 'function') ||
|
|
13
|
+
typeof Reflect.get(exported, 'getByName') !== 'function') {
|
|
14
|
+
throw error(`Export "${config.exportName}" is not a Durable Object namespace`);
|
|
15
|
+
}
|
|
16
|
+
return exported;
|
|
17
|
+
};
|
package/dist/errors.d.ts
CHANGED
|
@@ -67,6 +67,10 @@ export declare class FanoutSettlementError extends Error {
|
|
|
67
67
|
export declare class FanoutTimeoutError extends Error {
|
|
68
68
|
constructor(timeoutMs: number);
|
|
69
69
|
}
|
|
70
|
+
/** Error recorded when an outbox `publish` call exceeds its configured timeout. */
|
|
71
|
+
export declare class OutboxTimeoutError extends Error {
|
|
72
|
+
constructor(timeoutMs: number);
|
|
73
|
+
}
|
|
70
74
|
/** A definite rejection before the batch was durably accepted. */
|
|
71
75
|
export declare class FanoutEnqueueError extends Error {
|
|
72
76
|
constructor(message: string);
|
|
@@ -93,6 +97,10 @@ export declare class LogTruncatedError extends Error {
|
|
|
93
97
|
export declare class LogLeaseError extends Error {
|
|
94
98
|
constructor(batchId: string);
|
|
95
99
|
}
|
|
100
|
+
/** A malformed or unexpected semaphore message. */
|
|
101
|
+
export declare class SemaphoreProtocolError extends Error {
|
|
102
|
+
constructor(message: string);
|
|
103
|
+
}
|
|
96
104
|
/** Error thrown when a sharding function returns an invalid shard key. */
|
|
97
105
|
export declare class RoutingError extends Error {
|
|
98
106
|
constructor(message: string);
|
package/dist/errors.js
CHANGED
|
@@ -105,6 +105,13 @@ export class FanoutTimeoutError extends Error {
|
|
|
105
105
|
this.name = 'FanoutTimeoutError';
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
+
/** Error recorded when an outbox `publish` call exceeds its configured timeout. */
|
|
109
|
+
export class OutboxTimeoutError extends Error {
|
|
110
|
+
constructor(timeoutMs) {
|
|
111
|
+
super(`Outbox publication timed out after ${timeoutMs}ms`);
|
|
112
|
+
this.name = 'OutboxTimeoutError';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
108
115
|
/** A definite rejection before the batch was durably accepted. */
|
|
109
116
|
export class FanoutEnqueueError extends Error {
|
|
110
117
|
constructor(message) {
|
|
@@ -143,6 +150,13 @@ export class LogLeaseError extends Error {
|
|
|
143
150
|
this.name = 'LogLeaseError';
|
|
144
151
|
}
|
|
145
152
|
}
|
|
153
|
+
/** A malformed or unexpected semaphore message. */
|
|
154
|
+
export class SemaphoreProtocolError extends Error {
|
|
155
|
+
constructor(message) {
|
|
156
|
+
super(message);
|
|
157
|
+
this.name = 'SemaphoreProtocolError';
|
|
158
|
+
}
|
|
159
|
+
}
|
|
146
160
|
/** Error thrown when a sharding function returns an invalid shard key. */
|
|
147
161
|
export class RoutingError extends Error {
|
|
148
162
|
constructor(message) {
|
package/dist/experimental.d.ts
CHANGED
|
@@ -6,3 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { DurabilityTracker, type DurabilityTrackerConfig, type TrackedHandle, type TrackedItem, type TrackedResult, type TrackedWaitOptions, type TrackerHandle, type TrackerPage, type TrackerQuery, type TrackerRecord, type TrackerRecordPage, } from './tracker.js';
|
|
8
8
|
export type { TrackedEntry, TrackedPage, TrackedQuery, TrackedRecord, TrackedResults, TrackedSource, TrackedState, TrackedStatus, } from './tracked-source.js';
|
|
9
|
+
export { DurabilityOutbox, type DurabilityOutboxConfig, type DurabilityOutboxEvent, type OutboxEntry, } from './outbox.js';
|
|
10
|
+
export { OutboxTimeoutError } from './errors.js';
|
|
11
|
+
export { durabilityOutboxMigrations } from './migrations.js';
|
package/dist/experimental.js
CHANGED
package/dist/lifecycle.d.ts
CHANGED
|
@@ -17,7 +17,15 @@ export type FanoutLifecycleEntity = {
|
|
|
17
17
|
target: string;
|
|
18
18
|
generation: string;
|
|
19
19
|
};
|
|
20
|
-
export type
|
|
20
|
+
export type OutboxLifecycleEntity = {
|
|
21
|
+
entityKind: 'outbox_entry';
|
|
22
|
+
channel: string;
|
|
23
|
+
/** The staged key. */
|
|
24
|
+
id: string;
|
|
25
|
+
/** The staged version, as a string. */
|
|
26
|
+
generation: string;
|
|
27
|
+
};
|
|
28
|
+
export type LifecycleEntity = OperationLifecycleEntity | AlarmLifecycleEntity | FanoutLifecycleEntity | OutboxLifecycleEntity;
|
|
21
29
|
type AttemptSettled = {
|
|
22
30
|
type: 'attempt_settled';
|
|
23
31
|
timestamp: number;
|
|
@@ -25,7 +33,7 @@ type AttemptSettled = {
|
|
|
25
33
|
durationMs: number;
|
|
26
34
|
};
|
|
27
35
|
/** Best-effort metrics signal for queue lifecycle changes. */
|
|
28
|
-
export type DurabilityLifecycleEvent = ((OperationLifecycleEntity | FanoutLifecycleEntity) & {
|
|
36
|
+
export type DurabilityLifecycleEvent = ((OperationLifecycleEntity | FanoutLifecycleEntity | OutboxLifecycleEntity) & {
|
|
29
37
|
type: 'registered';
|
|
30
38
|
timestamp: number;
|
|
31
39
|
attempt: 0;
|
|
@@ -74,5 +82,8 @@ export declare const createLifecycleHooks: (emitter: (hook: LifecycleHook) => Em
|
|
|
74
82
|
* Wraps a consumer hook so it can never affect queue state: synchronous throws
|
|
75
83
|
* and rejections are logged, and promises ride on `waitUntil` when available.
|
|
76
84
|
*/
|
|
77
|
-
export declare const createEmitter:
|
|
85
|
+
export declare const createEmitter: <Event extends {
|
|
86
|
+
entityKind: string;
|
|
87
|
+
type: string;
|
|
88
|
+
} = DurabilityLifecycleEvent>(hook: ((event: Event) => void | Promise<void>) | undefined, waitUntil: ((promise: Promise<unknown>) => void) | undefined) => ((event: Event) => void);
|
|
78
89
|
export {};
|
package/dist/migrations.d.ts
CHANGED
|
@@ -55,6 +55,33 @@ export declare const durabilityLogLeaseMigrations: {
|
|
|
55
55
|
up: string;
|
|
56
56
|
down: string;
|
|
57
57
|
}[];
|
|
58
|
+
/**
|
|
59
|
+
* Ordered SQLite migrations for outbox channels. Applied automatically on
|
|
60
|
+
* construction.
|
|
61
|
+
*/
|
|
62
|
+
export declare const durabilityOutboxMigrations: {
|
|
63
|
+
name: string;
|
|
64
|
+
up: string;
|
|
65
|
+
down: string;
|
|
66
|
+
}[];
|
|
67
|
+
/**
|
|
68
|
+
* Ordered SQLite migrations for semaphore grants. Applied automatically on
|
|
69
|
+
* construction.
|
|
70
|
+
*/
|
|
71
|
+
export declare const durabilitySemaphoreMigrations: {
|
|
72
|
+
name: string;
|
|
73
|
+
up: string;
|
|
74
|
+
down: string;
|
|
75
|
+
}[];
|
|
76
|
+
/**
|
|
77
|
+
* Ordered SQLite migrations for a semaphore client's queue. Applied
|
|
78
|
+
* automatically on construction.
|
|
79
|
+
*/
|
|
80
|
+
export declare const durabilitySemaphoreQueueMigrations: {
|
|
81
|
+
name: string;
|
|
82
|
+
up: string;
|
|
83
|
+
down: string;
|
|
84
|
+
}[];
|
|
58
85
|
/** Migration names changed by one migrate call. */
|
|
59
86
|
export type DurabilityMigrationResult = {
|
|
60
87
|
/** Migrations applied in ascending order. */
|
|
@@ -62,7 +89,7 @@ export type DurabilityMigrationResult = {
|
|
|
62
89
|
/** Migrations reverted in descending order. */
|
|
63
90
|
rolledBack: string[];
|
|
64
91
|
};
|
|
65
|
-
export type MigrationCapability = 'operations' | 'namedAlarms' | 'fanout' | 'socket' | 'log' | 'logLeases';
|
|
92
|
+
export type MigrationCapability = 'operations' | 'namedAlarms' | 'fanout' | 'socket' | 'log' | 'logLeases' | 'outbox' | 'semaphore' | 'semaphoreQueue';
|
|
66
93
|
type MigrationStorage = Pick<DurableObjectStorage, 'sql' | 'transactionSync'>;
|
|
67
94
|
/**
|
|
68
95
|
* Moves one capability's schema to a target migration, applying or reverting as
|
package/dist/migrations.js
CHANGED
|
@@ -322,6 +322,181 @@ export const durabilityLogLeaseMigrations = [
|
|
|
322
322
|
`,
|
|
323
323
|
},
|
|
324
324
|
];
|
|
325
|
+
/**
|
|
326
|
+
* Ordered SQLite migrations for outbox channels. Applied automatically on
|
|
327
|
+
* construction.
|
|
328
|
+
*/
|
|
329
|
+
export const durabilityOutboxMigrations = [
|
|
330
|
+
{
|
|
331
|
+
name: 'durability_0006_create_outbox',
|
|
332
|
+
up: `
|
|
333
|
+
CREATE TABLE IF NOT EXISTS durability_outbox (
|
|
334
|
+
id TEXT PRIMARY KEY,
|
|
335
|
+
channel TEXT NOT NULL,
|
|
336
|
+
entry_key TEXT NOT NULL,
|
|
337
|
+
version INTEGER NOT NULL,
|
|
338
|
+
payload TEXT NOT NULL,
|
|
339
|
+
status TEXT NOT NULL CHECK (status IN ('pending')),
|
|
340
|
+
attempt INTEGER NOT NULL DEFAULT 0,
|
|
341
|
+
next_attempt_at INTEGER NOT NULL,
|
|
342
|
+
last_error TEXT,
|
|
343
|
+
last_error_name TEXT,
|
|
344
|
+
created_at INTEGER NOT NULL,
|
|
345
|
+
generation_id TEXT NOT NULL
|
|
346
|
+
);
|
|
347
|
+
CREATE INDEX IF NOT EXISTS durability_outbox_due_idx
|
|
348
|
+
ON durability_outbox (channel, status, next_attempt_at, version);
|
|
349
|
+
CREATE INDEX IF NOT EXISTS durability_outbox_pending_idx
|
|
350
|
+
ON durability_outbox (status, next_attempt_at);
|
|
351
|
+
CREATE INDEX IF NOT EXISTS durability_outbox_created_idx
|
|
352
|
+
ON durability_outbox (created_at);
|
|
353
|
+
CREATE TABLE IF NOT EXISTS durability_outbox_seq (
|
|
354
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
355
|
+
next_version INTEGER NOT NULL
|
|
356
|
+
);
|
|
357
|
+
INSERT OR IGNORE INTO durability_outbox_seq (id, next_version) VALUES (1, 1);
|
|
358
|
+
`,
|
|
359
|
+
down: `
|
|
360
|
+
DROP INDEX IF EXISTS durability_outbox_due_idx;
|
|
361
|
+
DROP INDEX IF EXISTS durability_outbox_pending_idx;
|
|
362
|
+
DROP INDEX IF EXISTS durability_outbox_created_idx;
|
|
363
|
+
DROP TABLE IF EXISTS durability_outbox;
|
|
364
|
+
DROP TABLE IF EXISTS durability_outbox_seq;
|
|
365
|
+
`,
|
|
366
|
+
},
|
|
367
|
+
];
|
|
368
|
+
/**
|
|
369
|
+
* Ordered SQLite migrations for semaphore grants. Applied automatically on
|
|
370
|
+
* construction.
|
|
371
|
+
*/
|
|
372
|
+
export const durabilitySemaphoreMigrations = [
|
|
373
|
+
{
|
|
374
|
+
name: 'durability_0007_create_semaphore',
|
|
375
|
+
up: `
|
|
376
|
+
CREATE TABLE IF NOT EXISTS durability_semaphore_grants (
|
|
377
|
+
grant_id TEXT PRIMARY KEY,
|
|
378
|
+
client_id TEXT NOT NULL,
|
|
379
|
+
grp TEXT NOT NULL,
|
|
380
|
+
permits INTEGER NOT NULL,
|
|
381
|
+
claimed INTEGER NOT NULL DEFAULT 0,
|
|
382
|
+
released INTEGER NOT NULL DEFAULT 0,
|
|
383
|
+
created_at INTEGER NOT NULL,
|
|
384
|
+
expires_at INTEGER NOT NULL
|
|
385
|
+
);
|
|
386
|
+
CREATE INDEX IF NOT EXISTS durability_semaphore_grants_expires_idx
|
|
387
|
+
ON durability_semaphore_grants (expires_at) WHERE claimed < permits;
|
|
388
|
+
`,
|
|
389
|
+
down: `
|
|
390
|
+
DROP INDEX IF EXISTS durability_semaphore_grants_expires_idx;
|
|
391
|
+
DROP TABLE IF EXISTS durability_semaphore_grants;
|
|
392
|
+
`,
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: 'durability_0009_create_semaphore_leases',
|
|
396
|
+
up: `
|
|
397
|
+
CREATE TABLE IF NOT EXISTS durability_semaphore_leases (
|
|
398
|
+
lease_id TEXT PRIMARY KEY,
|
|
399
|
+
client_id TEXT NOT NULL,
|
|
400
|
+
grp TEXT NOT NULL,
|
|
401
|
+
permits INTEGER NOT NULL,
|
|
402
|
+
released INTEGER NOT NULL DEFAULT 0,
|
|
403
|
+
created_at INTEGER NOT NULL,
|
|
404
|
+
expires_at INTEGER NOT NULL,
|
|
405
|
+
retired INTEGER NOT NULL DEFAULT 0
|
|
406
|
+
);
|
|
407
|
+
CREATE INDEX IF NOT EXISTS durability_semaphore_leases_expires_idx
|
|
408
|
+
ON durability_semaphore_leases (expires_at);
|
|
409
|
+
`,
|
|
410
|
+
down: `
|
|
411
|
+
DROP INDEX IF EXISTS durability_semaphore_leases_expires_idx;
|
|
412
|
+
DROP TABLE IF EXISTS durability_semaphore_leases;
|
|
413
|
+
`,
|
|
414
|
+
},
|
|
415
|
+
];
|
|
416
|
+
/**
|
|
417
|
+
* Ordered SQLite migrations for a semaphore client's queue. Applied
|
|
418
|
+
* automatically on construction.
|
|
419
|
+
*/
|
|
420
|
+
export const durabilitySemaphoreQueueMigrations = [
|
|
421
|
+
{
|
|
422
|
+
name: 'durability_0008_create_semaphore_queue',
|
|
423
|
+
up: `
|
|
424
|
+
CREATE TABLE IF NOT EXISTS durability_semaphore_queue_items (
|
|
425
|
+
id TEXT PRIMARY KEY,
|
|
426
|
+
key TEXT NOT NULL,
|
|
427
|
+
grp TEXT NOT NULL,
|
|
428
|
+
payload TEXT NOT NULL,
|
|
429
|
+
status TEXT NOT NULL CHECK (status IN ('queued', 'claiming', 'admitted')),
|
|
430
|
+
grant_id TEXT,
|
|
431
|
+
created_at INTEGER NOT NULL,
|
|
432
|
+
admitted_at INTEGER,
|
|
433
|
+
notified INTEGER NOT NULL DEFAULT 0,
|
|
434
|
+
attempt INTEGER NOT NULL DEFAULT 0,
|
|
435
|
+
next_attempt_at INTEGER NOT NULL
|
|
436
|
+
);
|
|
437
|
+
CREATE INDEX IF NOT EXISTS durability_semaphore_queue_items_key_idx
|
|
438
|
+
ON durability_semaphore_queue_items (key, status, created_at, id);
|
|
439
|
+
CREATE INDEX IF NOT EXISTS durability_semaphore_queue_items_grant_idx
|
|
440
|
+
ON durability_semaphore_queue_items (grant_id, created_at, id);
|
|
441
|
+
CREATE INDEX IF NOT EXISTS durability_semaphore_queue_items_notify_idx
|
|
442
|
+
ON durability_semaphore_queue_items (next_attempt_at)
|
|
443
|
+
WHERE status = 'admitted' AND notified = 0;
|
|
444
|
+
CREATE TABLE IF NOT EXISTS durability_semaphore_queue_grants (
|
|
445
|
+
grant_id TEXT PRIMARY KEY,
|
|
446
|
+
key TEXT NOT NULL,
|
|
447
|
+
grp TEXT NOT NULL,
|
|
448
|
+
permits INTEGER NOT NULL,
|
|
449
|
+
claimed INTEGER NOT NULL DEFAULT 0,
|
|
450
|
+
confirmed INTEGER NOT NULL DEFAULT 0,
|
|
451
|
+
admitted INTEGER NOT NULL DEFAULT 0,
|
|
452
|
+
released INTEGER NOT NULL DEFAULT 0,
|
|
453
|
+
created_at INTEGER NOT NULL
|
|
454
|
+
);
|
|
455
|
+
CREATE INDEX IF NOT EXISTS durability_semaphore_queue_grants_key_idx
|
|
456
|
+
ON durability_semaphore_queue_grants (key, created_at);
|
|
457
|
+
CREATE TABLE IF NOT EXISTS durability_semaphore_queue_keys (
|
|
458
|
+
key TEXT PRIMARY KEY,
|
|
459
|
+
next_request_at INTEGER NOT NULL,
|
|
460
|
+
queued INTEGER NOT NULL
|
|
461
|
+
);
|
|
462
|
+
CREATE INDEX IF NOT EXISTS durability_semaphore_queue_keys_due_idx
|
|
463
|
+
ON durability_semaphore_queue_keys (next_request_at) WHERE queued > 0;
|
|
464
|
+
`,
|
|
465
|
+
down: `
|
|
466
|
+
DROP INDEX IF EXISTS durability_semaphore_queue_keys_due_idx;
|
|
467
|
+
DROP TABLE IF EXISTS durability_semaphore_queue_keys;
|
|
468
|
+
DROP INDEX IF EXISTS durability_semaphore_queue_grants_key_idx;
|
|
469
|
+
DROP TABLE IF EXISTS durability_semaphore_queue_grants;
|
|
470
|
+
DROP INDEX IF EXISTS durability_semaphore_queue_items_notify_idx;
|
|
471
|
+
DROP INDEX IF EXISTS durability_semaphore_queue_items_grant_idx;
|
|
472
|
+
DROP INDEX IF EXISTS durability_semaphore_queue_items_key_idx;
|
|
473
|
+
DROP TABLE IF EXISTS durability_semaphore_queue_items;
|
|
474
|
+
`,
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
name: 'durability_0010_add_semaphore_queue_leases',
|
|
478
|
+
up: `
|
|
479
|
+
ALTER TABLE durability_semaphore_queue_items ADD COLUMN lease_id TEXT;
|
|
480
|
+
CREATE TABLE IF NOT EXISTS durability_semaphore_queue_leases (
|
|
481
|
+
lease_id TEXT PRIMARY KEY,
|
|
482
|
+
key TEXT NOT NULL,
|
|
483
|
+
grp TEXT NOT NULL,
|
|
484
|
+
permits INTEGER NOT NULL,
|
|
485
|
+
drawn INTEGER NOT NULL DEFAULT 0,
|
|
486
|
+
released INTEGER NOT NULL DEFAULT 0,
|
|
487
|
+
created_at INTEGER NOT NULL,
|
|
488
|
+
expires_at INTEGER NOT NULL
|
|
489
|
+
);
|
|
490
|
+
CREATE INDEX IF NOT EXISTS durability_semaphore_queue_leases_key_idx
|
|
491
|
+
ON durability_semaphore_queue_leases (key, created_at);
|
|
492
|
+
`,
|
|
493
|
+
down: `
|
|
494
|
+
DROP INDEX IF EXISTS durability_semaphore_queue_leases_key_idx;
|
|
495
|
+
DROP TABLE IF EXISTS durability_semaphore_queue_leases;
|
|
496
|
+
ALTER TABLE durability_semaphore_queue_items DROP COLUMN lease_id;
|
|
497
|
+
`,
|
|
498
|
+
},
|
|
499
|
+
];
|
|
325
500
|
/**
|
|
326
501
|
* Newer library versions may leave migrations this one does not know about.
|
|
327
502
|
* On downgrade their stored `down` scripts are run, but only this many, so an
|
package/dist/outbox.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { DurabilityLifecycleEvent, LifecycleHook } from './lifecycle.js';
|
|
2
|
+
import { type DurabilityMigrationResult } from './migrations.js';
|
|
3
|
+
import { type DurabilityRetryOptions } from './policy.js';
|
|
4
|
+
import { type SchedulerAttachment } from './scheduler.js';
|
|
5
|
+
/** The newest staged version of one key, handed to `publish`. */
|
|
6
|
+
export type OutboxEntry<Value> = {
|
|
7
|
+
key: string;
|
|
8
|
+
/** Monotonic across the whole Durable Object; newer stages are larger. */
|
|
9
|
+
version: number;
|
|
10
|
+
value: Value;
|
|
11
|
+
/** One-based publication attempt for this version. */
|
|
12
|
+
attempt: number;
|
|
13
|
+
stagedAt: number;
|
|
14
|
+
/**
|
|
15
|
+
* Keeps this entry pending instead of acknowledging it when `publish`
|
|
16
|
+
* returns. Only callable while `publish` is running.
|
|
17
|
+
*/
|
|
18
|
+
retry(delayMs?: number): void;
|
|
19
|
+
};
|
|
20
|
+
export type DurabilityOutboxConfig<Value> = SchedulerAttachment & {
|
|
21
|
+
/**
|
|
22
|
+
* Stable channel ID. Outboxes on one scheduler share storage, partitioned by
|
|
23
|
+
* channel, and each owns its own `publish`. Defaults to `default`.
|
|
24
|
+
*/
|
|
25
|
+
channel?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Publishes a batch of the newest pending versions. Returning acknowledges
|
|
28
|
+
* every entry not marked with `retry()`; throwing retries the whole batch.
|
|
29
|
+
* Sinks must be idempotent on `(key, version)` and keep the highest version.
|
|
30
|
+
*/
|
|
31
|
+
publish(entries: OutboxEntry<Value>[]): unknown | Promise<unknown>;
|
|
32
|
+
/** Defaults to 50. */
|
|
33
|
+
maxBatchSize?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Rounds first publication up to the next multiple of this delay so stages
|
|
36
|
+
* within one window share a batch. Defaults to 0.
|
|
37
|
+
*/
|
|
38
|
+
batchDelayMs?: number;
|
|
39
|
+
/** Maximum duration of one `publish` call. Defaults to 60 seconds. */
|
|
40
|
+
attemptTimeoutMs?: number;
|
|
41
|
+
/** Publication is retried until acknowledged; only the delay is configurable. */
|
|
42
|
+
retries?: Pick<DurabilityRetryOptions, 'delay'>;
|
|
43
|
+
onLifecycleEvent?: LifecycleHook;
|
|
44
|
+
};
|
|
45
|
+
/** A lifecycle event for one of this outbox's entries. */
|
|
46
|
+
export type DurabilityOutboxEvent = Extract<DurabilityLifecycleEvent, {
|
|
47
|
+
entityKind: 'outbox_entry';
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Package-internal: stages inside a transaction another helper already holds,
|
|
51
|
+
* so its reports commit atomically with that helper's own rows. Assigned by
|
|
52
|
+
* the class's static block.
|
|
53
|
+
*/
|
|
54
|
+
export declare let stageWithin: <Value>(outbox: DurabilityOutbox<Value>, sql: SqlStorage, key: string, value: Value) => number;
|
|
55
|
+
/**
|
|
56
|
+
* A composable DO capability: keyed latest-state publication. Stage the
|
|
57
|
+
* newest value for a key in the same transaction as the state it describes;
|
|
58
|
+
* the outbox republishes the newest version until `publish` acknowledges it.
|
|
59
|
+
* Superseded versions are coalesced and may never be published.
|
|
60
|
+
*/
|
|
61
|
+
export declare class DurabilityOutbox<Value = unknown> {
|
|
62
|
+
#private;
|
|
63
|
+
constructor(config: DurabilityOutboxConfig<Value>);
|
|
64
|
+
static migrate(context: Pick<DurableObjectState, 'storage'>, target?: string | null): DurabilityMigrationResult;
|
|
65
|
+
alarm(info?: AlarmInvocationInfo): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Durably stages the newest value for `key` and returns its version. On a
|
|
68
|
+
* SQLite-backed object, staging inside `ctx.storage.transaction()` commits
|
|
69
|
+
* atomically with the application's own writes in that transaction.
|
|
70
|
+
*/
|
|
71
|
+
stage(key: string, value: Value): Promise<number>;
|
|
72
|
+
}
|