@restatedev/sessions 0.9.0 → 0.10.1

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.
Files changed (60) hide show
  1. package/README.md +131 -73
  2. package/dist/addon.d.ts +9 -0
  3. package/dist/addon.d.ts.map +1 -0
  4. package/dist/addon.js +20 -0
  5. package/dist/addon.js.map +1 -0
  6. package/dist/database.d.ts +13 -0
  7. package/dist/database.d.ts.map +1 -1
  8. package/dist/database.js +44 -17
  9. package/dist/database.js.map +1 -1
  10. package/dist/driver.d.ts +186 -0
  11. package/dist/driver.d.ts.map +1 -0
  12. package/dist/driver.js +554 -0
  13. package/dist/driver.js.map +1 -0
  14. package/dist/endpoint.d.ts +13 -0
  15. package/dist/endpoint.d.ts.map +1 -0
  16. package/dist/endpoint.js +186 -0
  17. package/dist/endpoint.js.map +1 -0
  18. package/dist/handler.d.ts +35 -0
  19. package/dist/handler.d.ts.map +1 -0
  20. package/dist/handler.js +218 -0
  21. package/dist/handler.js.map +1 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +2 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/internal.d.ts +4 -2
  26. package/dist/internal.d.ts.map +1 -1
  27. package/dist/internal.js +7 -3
  28. package/dist/internal.js.map +1 -1
  29. package/dist/object.d.ts +15 -2
  30. package/dist/object.d.ts.map +1 -1
  31. package/dist/object.js +51 -12
  32. package/dist/object.js.map +1 -1
  33. package/dist/serve.d.ts.map +1 -1
  34. package/dist/serve.js +5 -0
  35. package/dist/serve.js.map +1 -1
  36. package/dist/session.d.ts +32 -2
  37. package/dist/session.d.ts.map +1 -1
  38. package/dist/session.js +59 -9
  39. package/dist/session.js.map +1 -1
  40. package/dist/vm.d.ts +151 -0
  41. package/dist/vm.d.ts.map +1 -0
  42. package/dist/vm.js +28 -0
  43. package/dist/vm.js.map +1 -0
  44. package/package.json +4 -4
  45. package/src/addon.ts +29 -0
  46. package/src/database.ts +48 -19
  47. package/src/driver.ts +657 -0
  48. package/src/endpoint.ts +220 -0
  49. package/src/handler.ts +272 -0
  50. package/src/index.ts +2 -1
  51. package/src/internal.ts +7 -4
  52. package/src/object.ts +75 -13
  53. package/src/serve.ts +5 -0
  54. package/src/session.ts +77 -8
  55. package/src/vm.ts +195 -0
  56. package/dist/selector.d.ts +0 -129
  57. package/dist/selector.d.ts.map +0 -1
  58. package/dist/selector.js +0 -251
  59. package/dist/selector.js.map +0 -1
  60. package/src/selector.ts +0 -323
package/README.md CHANGED
@@ -17,6 +17,12 @@ It runs on a released Restate server and the published SDK, version 1.18.2,
17
17
  which it pins ([why](#concurrent-awaits)). See
18
18
  [the requirements](../../README.md#requirements).
19
19
 
20
+ A session object needs a Restate that speaks **service protocol v7 or later**
21
+ — 1.5 and up. Its VM accepts no less, and an invocation that negotiates an
22
+ older protocol is refused with a 415 that says so. Journaled services and
23
+ virtual objects are unaffected: they are the SDK's, at any version it
24
+ supports.
25
+
20
26
  ```ts
21
27
  import * as restate from '@restatedev/sessions';
22
28
 
@@ -93,9 +99,11 @@ over the real one.
93
99
 
94
100
  `RESTATE_SERVE_ONLY=a,b` serves only the services it names, each with what
95
101
  it needs: one program, deployed in parts. For anything else (another port,
96
- HTTP/1.1, a Lambda handler), the SDK's `restate.endpoint()` is there as
97
- ever: bind it what `restate.served([...services])` lists, the services with
98
- what they need.
102
+ an HTTP/1.1 server), the SDK's `restate.endpoint()` is there as ever: bind
103
+ it what `restate.served([...services])` lists, the services with what they
104
+ need. A session object needs a bidirectional stream, so an HTTP/1.1 handler
105
+ serves one only when built with `{ bidirectional: true }`
106
+ ([not supported](#not-supported)).
99
107
 
100
108
  ### The contexts
101
109
 
@@ -148,8 +156,9 @@ views: {
148
156
  ## Retries
149
157
 
150
158
  A handler runs in attempts. Restate starts a new attempt after a crash, a
151
- retryable error or a suspension, and every attempt runs the handler from its
152
- first line. A commit is durable once its promise resolves, and every later
159
+ retryable error or a shutdown of the attempt (see
160
+ [the caveats](#caveats)), and every attempt runs the handler from its first
161
+ line. A commit is durable once its promise resolves, and every later
153
162
  attempt sees it. An error, terminal or not, doesn't undo what the handler
154
163
  already committed.
155
164
 
@@ -242,11 +251,11 @@ ctx.send(audit).record(entry);
242
251
  ```
243
252
 
244
253
  The SDK never makes up idempotency keys: a call has one only if you pass it.
245
- With a key, a new attempt, including one resuming from a suspension, reaches
246
- the invocation the first attempt started and gets its result. Build the key
247
- from the request id and what the call is for. Restate scopes keys to the
248
- target handler and remembers them for the target's idempotency retention, a
249
- day by default.
254
+ With a key, a new attempt, including one Restate starts when the call
255
+ answers, reaches the invocation the first attempt started and gets its
256
+ result. Build the key from the request id and what the call is for. Restate
257
+ scopes keys to the target handler and remembers them for the target's
258
+ idempotency retention, a day by default.
250
259
 
251
260
  A key names one call. If an invocation makes the same call several times,
252
261
  once per tool call for example, add something to the key that tells them
@@ -277,18 +286,18 @@ with an idempotency key instead, which gives every attempt the same answer
277
286
  ([calls and sends](#calls-and-sends)).
278
287
 
279
288
  A cancellation reaches a handler as Restate's reaches any handler: once, at
280
- the awaits pending when it comes, which fail with a `CancelledError`. The
281
- session adds nothing to it. A `ctx.db` call is one such await: the request
282
- of its own to Restate that a cancellation reaches (a read, or the sync a
283
- commit waits for) fails, and so does the call. What the call sent to Restate
284
- before that await stays: a commit's writes, and its transaction's sends,
285
- which are made right after the writes, before the commit waits for anything.
286
- So a `CancelledError` from `transaction()` doesn't say whether it committed,
287
- as no cancelled await does: the database does. If it committed, its sends
288
- are made, once.
289
-
290
- The calls after it work: the next opens the session again, and reads what
291
- is stored. So a handler can check what committed, and compensate:
289
+ an await, which fails with a `CancelledError`. The awaits of Restate pending
290
+ when it comes fail (a `ctx.rpc`, a `wait`). A `ctx.db` call is treated
291
+ differently, so that its failure means one thing: a call already under way
292
+ when the cancellation comes runs to its end, and the cancellation goes to
293
+ what the handler awaits next; a `ctx.db` call that fails with a
294
+ `CancelledError` was refused before it began. So a `CancelledError` from
295
+ `ctx.db` says the call did nothing: it wrote nothing, and a `transaction()`
296
+ neither committed nor made its sends. A transaction that resolves committed,
297
+ and its sends are made, once.
298
+
299
+ The calls after it work. So a handler can compensate, or make the call
300
+ again:
292
301
 
293
302
  ```ts
294
303
  try {
@@ -305,10 +314,12 @@ try {
305
314
  A transaction whose body awaits something else (a `ctx.rpc`) that a
306
315
  cancellation reaches fails with it and rolls back, unless the body catches
307
316
  it. A retry of a cancelled invocation, after a crash, gets the cancellation
308
- at its first await, which may be the open that makes what the crash left in
309
- the outbox. No attempt follows a cancelled one, so as an attempt ends, a
317
+ at its first await; the open that makes what the crash left in the outbox is
318
+ the session's own, and is not failed. No attempt follows a cancelled one, so as an attempt ends, a
310
319
  session that a failure ended is opened again, which makes what the outbox
311
- holds and empties it.
320
+ holds and empties it. Once Restate has shut an attempt down, a cancellation
321
+ carried to its next await is not delivered: what the handler does then
322
+ fails with the attempt's end, and the next attempt gets the cancellation.
312
323
 
313
324
  ## Sends in a transaction
314
325
 
@@ -331,8 +342,9 @@ with the idempotency key `transaction/<id>/<index>` (or the send's own key),
331
342
  where `<id>` is a random id of the transaction. Then, before `transaction()`
332
343
  resolves, a second commit empties the outbox. Restate stores an attempt's
333
344
  commands in order, so the sends are stored by the time that commit is. An
334
- attempt that suspends later, to wait days for an approval for example, has
335
- nothing left to send again when it resumes, long after the keys expired.
345
+ attempt that Restate shuts down later, while it waits days for an approval
346
+ for example, leaves the next attempt nothing to send again, long after the
347
+ keys expired.
336
348
 
337
349
  If an attempt ends between the two commits, the sends stay in the outbox.
338
350
  The next exclusive attempt opens the database when it starts, and sends them
@@ -356,25 +368,30 @@ record its outcome in the transaction. The shop's `Orders` does this, and its
356
368
 
357
369
  **Where the data lives.** The database is stored in the object's state,
358
370
  under the keys `v22/head`, `v22/tail/…`, `v22/manifest/…` and `v22/pack/…`.
359
- Reads are `ctx.get`, writes are `ctx.set` and `ctx.clear`, and a sync is an
360
- empty `ctx.run`. Handlers and views can't reach any other state key, since
361
- a session has no key/value state of its own.
362
-
363
- **Reads and writes.** A read is a state read. It is journaled for now (once
364
- protocol v8 ships it won't be), and it goes
365
- to the runtime unless this attempt wrote the key or the invocation started
366
- with it. An invocation starts with only the database's head (`state:
367
- { preload: ['v22/head'] }`): its open's first read needs no round trip, and
368
- it doesn't start by loading every page. A write or a clear is a state write, and returns at once.
369
- Restate keeps an attempt's writes and sends in the order they were made, so
370
- a crash can lose the last ones, but never a write without those before it.
371
+ The addon reads and writes them as the attempt's own state commands, and a
372
+ write that must be stored before the database goes on asks Restate to ack
373
+ it. Handlers and views can't reach any other state key, since a session has
374
+ no key/value state of its own.
375
+
376
+ **Reads and writes.** A read is a state read. It goes to the runtime unless
377
+ this attempt wrote the key or the invocation started with it. An invocation
378
+ starts with only the database's head (`state: { preload: ['v22/head'] }`):
379
+ its open's first read needs no round trip, and it doesn't start by loading
380
+ every page. On service protocol v8, a read that goes to the runtime is an
381
+ ephemeral get, which the journal doesn't record; on v7, which Restate 1.8
382
+ negotiates, it is a lazy get, recorded in the journal with its value. A
383
+ write or a clear is a state write, and returns at once. Restate keeps an
384
+ attempt's writes and sends in the order they were made, so a crash can lose
385
+ the last ones, but never a write without those before it.
371
386
 
372
387
  **Commits.** A transaction writes the pages it changed, and its records, as
373
388
  one tail entry under a key of its own. Then it writes the head, which points
374
- to that entry; this is the commit point. One empty `ctx.run` then waits until
375
- all of it is stored, so a commit is one round trip. Whatever a crash keeps,
376
- the stored head only points to tail entries and checkpoints that are stored
377
- too. Now and then, a commit first folds the tail into a checkpoint (see the
389
+ to that entry; this is the commit point. The head's write asks Restate for
390
+ an ack, which Restate gives only once the writes before it are stored, and
391
+ the commit waits for that ack, so a commit is one round trip. Whatever a
392
+ crash keeps, the stored head only points to tail entries and checkpoints
393
+ that are stored too. Now and then, a commit first folds the tail into a
394
+ checkpoint (see the
378
395
  [state's architecture](native/src/state/docs/ARCHITECTURE.md)).
379
396
 
380
397
  **The page cache.** The process caches the pages it read and wrote, and the
@@ -402,13 +419,28 @@ cluster its own path, because a database deletes the packs under its
402
419
  directory that its own head does not need. A URL that names no store fails
403
420
  every open with its message.
404
421
 
422
+ `RESTATE_SQL_L0_BYTES` sets those 4 MiB (bytes, or with `KiB`, `MiB` or
423
+ `GiB`, read at the process's first open). `0` puts every checkpoint's pack
424
+ in the object store, however small the database. Restate then keeps only
425
+ the head, the tail of recent commits (up to two checkpoints' worth: 128
426
+ commits or 1 MiB each, plus the commit that passed it) and the last two
427
+ checkpoints' manifests (a few bytes per 16 KiB of database, and records of
428
+ up to 1 KiB). A cold read of anything older than the tail is an object
429
+ store read, and each checkpoint, every 128 commits or so, an upload and a
430
+ listing of the database's directory. Until its first checkpoint, a
431
+ database is all tail, in Restate. The value may change from one deployment
432
+ to the next: a lower one moves what Restate holds at the next checkpoint, a
433
+ higher one keeps the checkpoints after it in Restate, and packs never move
434
+ back. Without `RESTATE_SQL_OBJECT_STORE` it changes nothing; a value that
435
+ is not a size fails every open with its message.
436
+
405
437
  **No journal replay.** On a retry or a resume, the SDK normally replays the
406
438
  journal: each operation returns its recorded result, and must match it.
407
439
  That can't work here, because a later attempt makes different reads,
408
440
  depending on what the page cache holds. With explicit recovery
409
441
  (`restate.internal.explicitRecovery()`, which every session handler and view
410
- has), the SDK skips the recorded journal, and the handler runs again from
411
- the start against the state as it is. Recovery is then up to the storage:
442
+ has), the attempt skips the recorded journal, and the handler runs again
443
+ from the start against the state as it is. Recovery is then up to the storage:
412
444
  opening the database reads the head, so a commit the crashed attempt didn't
413
445
  finish is as if it never started.
414
446
 
@@ -419,7 +451,7 @@ alongside them.
419
451
 
420
452
  ## Concurrent awaits
421
453
 
422
- You can await a context's calls (the SDK's `RestatePromise`s) and the
454
+ You can await a context's calls and the
423
455
  database's calls concurrently: with `Promise.all`, `Promise.race`, your own
424
456
  combinators, several async functions at once, or a library's. The database's
425
457
  own reads run concurrently too.
@@ -427,25 +459,31 @@ own reads run concurrently too.
427
459
  On its own, the published SDK drives each awaited promise with a loop of its
428
460
  own, and lets only one of them wait for the server at a time
429
461
  (`ExternalProgressChannel`). A second waiter fails the attempt with
430
- `awaitNext already pending`, and it is retried forever. So session handlers
431
- drive every promise they await with a single loop,
432
- [the selector](src/selector.ts). Before the handler runs, it takes over the
433
- invocation's `promisesExecutor.doProgress`, and gives it back when the
434
- attempt ends. These are SDK internals as of 1.18.2, so the package pins that
435
- version, and refuses to run a handler on an SDK without them.
436
- [`test/selector.test.ts`](test/selector.test.ts) tests the selector against
437
- a fake VM and the SDK's single-waiter channel.
462
+ `awaitNext already pending`, and it is retried forever.
463
+
464
+ A session object does not run on that VM. It runs on shared-core's
465
+ `ExplicitRecoveryVM`, the state machine for handlers that are never replayed
466
+ ([`docs/explicit-recovery.md`](docs/explicit-recovery.md)): a command returns
467
+ a notification handle, results come back in any order, and the driver settles
468
+ each promise as its handle is notified. There is no single await point to
469
+ contend for, so a handler awaits whatever it likes.
470
+
471
+ `src/endpoint.ts` routes a session object's invocation there, by patching
472
+ `NodeEndpoint.prototype` — the class `restate.endpoint()`, `restate.serve`
473
+ and `connect`'s tunnel all build theirs from. That prototype and the
474
+ endpoint's builder are SDK internals as of 1.18.2, so the package pins that
475
+ version. A fetch or Lambda endpoint is not built from it and cannot serve a
476
+ session object; it is refused rather than half-served.
438
477
 
439
478
  What you get:
440
479
 
441
- - **One await point.** The loop asks the server about all awaited promises
442
- at once. After a suspension, the handler resumes on the first of them to
443
- complete, and a promise awaited while the loop waits joins its next check,
444
- so a call awaited late isn't held up by a slow call made earlier.
480
+ - **No await point to contend for.** Every awaited promise waits on its own
481
+ handle, so a call awaited late isn't held up by a slow call made earlier.
445
482
  - **An operation starts when you make it.** A call goes out without an
446
483
  `await`, and a failure nobody awaits is not an unhandled rejection.
447
- - **Cancellation reaches every awaited promise**, and each one rejects with
448
- `CancelledError`.
484
+ - **Cancellation reaches every awaited call**, and each one rejects with
485
+ `CancelledError`; a `ctx.db` call already under way runs to its end
486
+ ([cancelling an invocation](#cancelling-an-invocation)).
449
487
 
450
488
  ```ts
451
489
  const quote = restate.sessionObject({
@@ -502,22 +540,39 @@ storage in the session's database.
502
540
 
503
541
  ## Caveats
504
542
 
505
- - **Every read is journaled with its value.** A state read adds the value to
506
- the invocation's journal, so reading pages costs log writes, and the page
507
- cache matters more than usual. A completed invocation's journal, reads
508
- included, is kept for Restate's default retention.
543
+ - **On protocol v7, every read is journaled with its value.** A state read
544
+ that goes to the runtime adds the value to the invocation's journal, so
545
+ reading pages costs log writes, and the page cache matters more than
546
+ usual. Restate 1.8 negotiates v7; on v8 such a read is ephemeral. A
547
+ completed invocation's journal, reads included, is kept for Restate's
548
+ default retention.
509
549
  - **The journal grows across attempts.** Entries an attempt skips stay, and
510
550
  each attempt adds its own.
511
- - **A suspension is a restart.** Resuming means running from the start, so a
512
- long handler that hits the inactivity timeout starts over.
513
- - **One sync per commit.** Every commit waits for an empty `ctx.run` after
514
- its head, a round trip to the runtime. Statements that commit one by one
515
- pay it each time, so group them in a transaction.
551
+ - **A shutdown is a restart.** Restate shuts an attempt down once its
552
+ inactivity timeout passes with nothing heard from it, and the next attempt
553
+ runs from the start. While the handler works outside Restate (a model
554
+ request, say), the attempt sends a heartbeat every 20 seconds
555
+ (`RESTATE_SESSIONS_HEARTBEAT`, in milliseconds), so a long handler keeps
556
+ its attempt. A deployment that shortens Restate's inactivity timeout must
557
+ shorten this with it. No heartbeat is sent while an answer of Restate's is
558
+ outstanding (a call's result or invocation id, a send's invocation id, an
559
+ attachment), even one nobody awaits: Restate then shuts the attempt down
560
+ after the timeout, and starts the next one when the answer comes. The
561
+ database's own reads and acks don't stop a heartbeat.
562
+ - **A cancellation waits for the call.** Cancelling an invocation whose
563
+ attempt Restate shut down while it waited for a call takes effect only
564
+ when that call answers: until then the invocation stays suspended, for
565
+ good if the call never answers. So an agent's `stop` leaves a turn that
566
+ waits on an approval suspended, and `status` still shows it answering,
567
+ until the approval comes; the turn then ends cancelled.
568
+ - **One acked write per commit.** Every commit waits for Restate to ack its
569
+ head's write, a round trip to the runtime. Statements that commit one by
570
+ one pay it each time, so group them in a transaction.
516
571
  - **10 GiB per database.** A statement that would grow a key's database past
517
572
  that fails with SQLite's "database or disk is full", as an SQL error (a
518
573
  `TerminalError`), and `ctx.db` keeps working.
519
- - **Assumptions still to confirm with the runtime.** An empty `ctx.run` is
520
- acknowledged only after the commands before it are stored (the sync). An
574
+ - **Assumptions still to confirm with the runtime.** A state write's ack
575
+ comes only after the commands before it are stored (the sync). An
521
576
  abandoned attempt's commands are never applied after a new attempt starts
522
577
  (fencing). State that a lazy read returns is durable. The crash tests kill
523
578
  processes, so they check recovery, not durability across a machine crash.
@@ -527,8 +582,11 @@ storage in the session's database.
527
582
  - Key/value state, durable steps, timers and awakeables in a session object.
528
583
  Put them in a regular `restate.object`, `service` or `workflow`, and call
529
584
  it.
530
- - Request/response deployments, such as Lambda. They suspend at every
531
- await, and for a session a suspension is a restart.
585
+ - Request/response deployments, such as Lambda. A session object needs a
586
+ bidirectional stream. A handler of `restate.endpoint()` that has none
587
+ (HTTP/1.1, unless built with `{ bidirectional: true }`, or HTTP/2 built
588
+ with `{ bidirectional: false }`) fails the invocation, which pauses it. A
589
+ fetch or Lambda endpoint refuses it.
532
590
 
533
591
  ## Tests
534
592
 
@@ -0,0 +1,9 @@
1
+ /** What the addon exports. Its types live with what uses them. */
2
+ interface Addon {
3
+ open(namespace: string, store: unknown, reader: boolean): Promise<unknown>;
4
+ Vm: unknown;
5
+ Identity: unknown;
6
+ }
7
+ export declare const addon: Addon;
8
+ export {};
9
+ //# sourceMappingURL=addon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addon.d.ts","sourceRoot":"","sources":["../src/addon.ts"],"names":[],"mappings":"AAKA,kEAAkE;AAClE,UAAU,KAAK;IACb,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3E,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;CACnB;AAkBD,eAAO,MAAM,KAAK,OAAS,CAAC"}
package/dist/addon.js ADDED
@@ -0,0 +1,20 @@
1
+ // The addon (`native/`), loaded once: the database of a session
2
+ // (`database.ts`) and the VM of an attempt (`vm.ts`) both come from it.
3
+ import { createRequire } from 'node:module';
4
+ import { PLATFORMS, platform } from './platform.js';
5
+ /** The addon of this machine's platform, from its package (see platform.ts). */
6
+ function load() {
7
+ const machine = platform();
8
+ const name = `@restatedev/sessions-${machine}`;
9
+ try {
10
+ return createRequire(import.meta.url)(name);
11
+ }
12
+ catch (error) {
13
+ if (error.code !== 'MODULE_NOT_FOUND')
14
+ throw error;
15
+ throw new Error(`@restatedev/sessions found no addon for ${machine}, the package ${name}: it ships them for ` +
16
+ `${PLATFORMS.join(', ')}. In its repository, \`pnpm build\` builds this machine's.`, { cause: error });
17
+ }
18
+ }
19
+ export const addon = load();
20
+ //# sourceMappingURL=addon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addon.js","sourceRoot":"","sources":["../src/addon.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,wEAAwE;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AASpD,gFAAgF;AAChF,SAAS,IAAI;IACX,MAAM,OAAO,GAAG,QAAQ,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,wBAAwB,OAAO,EAAE,CAAC;IAC/C,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAU,CAAC;IACvD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA+B,CAAC,IAAI,KAAK,kBAAkB;YAAE,MAAM,KAAK,CAAC;QAC9E,MAAM,IAAI,KAAK,CACb,2CAA2C,OAAO,iBAAiB,IAAI,sBAAsB;YAC3F,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,4DAA4D,EACrF,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { Buffer } from 'node:buffer';
2
+ import { type Vm } from './vm.ts';
2
3
  /** An SQL value. Integers come back as numbers, or as bigints beyond 2^53. */
3
4
  export type SqlValue = null | number | bigint | string | Uint8Array;
4
5
  /** An SQL parameter: an `SqlValue`, or a boolean, stored as 0 or 1. */
@@ -91,6 +92,18 @@ type Answer<T> = T | Promise<T>;
91
92
  export declare function open(namespace: string, store: Store, { reader }?: {
92
93
  reader?: boolean | undefined;
93
94
  }): Promise<Connection>;
95
+ /**
96
+ * Open the database of `namespace` over the attempt's VM: the state is read
97
+ * and written as the VM's own commands, in the addon, so none of it crosses
98
+ * into JavaScript. `store` is called at one point only — its `sync`, which the
99
+ * boundary uses to run what the committing transaction gave
100
+ * {@link ConnectionTransaction.withCommit} — so its `get`, `set` and `clear`
101
+ * are never reached. `name` names a database beside the object's own.
102
+ */
103
+ export declare function openOnVm(namespace: string, store: Store, vm: Vm, { name, reader }?: {
104
+ name?: string;
105
+ reader?: boolean;
106
+ }): Promise<Connection>;
94
107
  /**
95
108
  * The store as the addon calls it. An error of the store's crosses the addon
96
109
  * as text, which ends the session: the first is kept here, and the calls that
@@ -1 +1 @@
1
- {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,8EAA8E;AAC9E,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;AAEpE,uEAAuE;AACvE,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE1C,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7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  // (`native/src/node.rs`); this module orders the calls and runs transactions.
5
5
  import { AsyncLocalStorage } from 'node:async_hooks';
6
6
  import { Buffer } from 'node:buffer';
7
- import { createRequire } from 'node:module';
8
- import { PLATFORMS, platform } from './platform.js';
7
+ import { addon as loaded } from './addon.js';
8
+ import { STATE_WAIT_OVER } from './vm.js';
9
+ import { AttemptShutDown } from './driver.js';
9
10
  /**
10
11
  * A failure a retry would repeat: SQL the engine rejected (a syntax error, a
11
12
  * constraint, a missing table), which undid just that statement and leaves
@@ -47,21 +48,7 @@ export function sqlOver(run, failure = (error) => error) {
47
48
  execute: async (sql, params) => void (await run(sql, params)),
48
49
  };
49
50
  }
50
- const addon = load();
51
- /** The addon of this machine's platform, from its package (see platform.ts). */
52
- function load() {
53
- const machine = platform();
54
- const name = `@restatedev/sessions-${machine}`;
55
- try {
56
- return createRequire(import.meta.url)(name);
57
- }
58
- catch (error) {
59
- if (error.code !== 'MODULE_NOT_FOUND')
60
- throw error;
61
- throw new Error(`@restatedev/sessions found no addon for ${machine}, the package ${name}: it ships them for ` +
62
- `${PLATFORMS.join(', ')}. In its repository, \`pnpm build\` builds this machine's.`, { cause: error });
63
- }
64
- }
51
+ const addon = loaded;
65
52
  /**
66
53
  * Open the database of `namespace` over `store`. One process-wide page cache
67
54
  * serves every namespace. A `reader` reads beside the namespace's owner (a
@@ -76,6 +63,26 @@ export async function open(namespace, store, { reader = false } = {}) {
76
63
  throw boundary.failed?.error ?? error;
77
64
  }
78
65
  }
66
+ /**
67
+ * Open the database of `namespace` over the attempt's VM: the state is read
68
+ * and written as the VM's own commands, in the addon, so none of it crosses
69
+ * into JavaScript. `store` is called at one point only — its `sync`, which the
70
+ * boundary uses to run what the committing transaction gave
71
+ * {@link ConnectionTransaction.withCommit} — so its `get`, `set` and `clear`
72
+ * are never reached. `name` names a database beside the object's own.
73
+ */
74
+ export async function openOnVm(namespace, store, vm, { name, reader = false } = {}) {
75
+ const boundary = new Boundary(store);
76
+ try {
77
+ return new Connection(await addon.openOnVm(namespace, boundary, vm, name, reader), boundary);
78
+ }
79
+ catch (error) {
80
+ // The open reads the database's head. On this path that read waits in the
81
+ // addon, so its failure arrives as text and `boundary.failed` is never
82
+ // set: a cancellation here must still reach the handler as one.
83
+ throw stateWaitFailure(error) ?? boundary.failed?.error ?? error;
84
+ }
85
+ }
79
86
  /**
80
87
  * The store as the addon calls it. An error of the store's crosses the addon
81
88
  * as text, which ends the session: the first is kept here, and the calls that
@@ -173,6 +180,13 @@ class Sql {
173
180
  failure(error) {
174
181
  if (error instanceof SqlError)
175
182
  return error;
183
+ // The state is read and written in the addon on the VM's path, so the
184
+ // end of the attempt fails those waits there and its text is all that
185
+ // crosses back. Give the handler the class the driver's own awaits fail
186
+ // with.
187
+ const stateWait = stateWaitFailure(error);
188
+ if (stateWait !== undefined)
189
+ return stateWait;
176
190
  const failed = this.boundary.failed;
177
191
  if (failed !== undefined && !this.native.isUsable())
178
192
  return failed.error;
@@ -183,6 +197,19 @@ class Sql {
183
197
  // The code of the addon's errors that a retry would repeat even though they
184
198
  // ended the session (its `Refused`), and of arguments it cannot convert.
185
199
  const REFUSED = 'InvalidArg';
200
+ /**
201
+ * The error of a call that failed because the attempt's state waits were
202
+ * failed in the addon, at the end of the attempt. `undefined` for anything
203
+ * else.
204
+ */
205
+ function stateWaitFailure(error) {
206
+ const message = error.message;
207
+ if (typeof message !== 'string')
208
+ return undefined;
209
+ if (message.includes(STATE_WAIT_OVER))
210
+ return new AttemptShutDown();
211
+ return undefined;
212
+ }
186
213
  /**
187
214
  * A session of a database: calls run one at a time, in call order, and a
188
215
  * transaction holds the session until it commits or rolls back. Calls made
@@ -1 +1 @@
1
- {"version":3,"file":"database.js","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,kFAAkF;AAClF,0EAA0E;AAC1E,8EAA8E;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,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