@restatedev/sessions 0.1.0 → 0.3.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 +54 -8
- package/dist/database.d.ts +41 -2
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +99 -20
- package/dist/database.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +6 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +5 -2
- package/dist/internal.js.map +1 -1
- package/dist/link.d.ts +10 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +19 -0
- package/dist/link.js.map +1 -0
- package/dist/object.d.ts +17 -4
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +61 -46
- package/dist/object.js.map +1 -1
- package/dist/schema.d.ts +7 -6
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +9 -10
- package/dist/schema.js.map +1 -1
- package/dist/scope.d.ts +38 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +55 -0
- package/dist/scope.js.map +1 -0
- package/dist/serve.d.ts +21 -0
- package/dist/serve.d.ts.map +1 -0
- package/dist/serve.js +49 -0
- package/dist/serve.js.map +1 -0
- package/dist/session.d.ts +70 -34
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +273 -221
- package/dist/session.js.map +1 -1
- package/package.json +4 -4
- package/src/database.ts +111 -22
- package/src/index.ts +4 -1
- package/src/internal.ts +16 -3
- package/src/link.ts +22 -0
- package/src/object.ts +94 -63
- package/src/schema.ts +11 -10
- package/src/scope.ts +78 -0
- package/src/serve.ts +54 -0
- package/src/session.ts +273 -230
package/README.md
CHANGED
|
@@ -59,6 +59,13 @@ SDK handlers (`restate.handlers.*`) aren't accepted. Journaled work belongs
|
|
|
59
59
|
in a regular `restate.object`, `restate.service` or `restate.workflow`, which
|
|
60
60
|
your session object can call.
|
|
61
61
|
|
|
62
|
+
`restate.serve(...services)` serves them, session objects and the SDK's
|
|
63
|
+
alike, on `PORT` (9080 by default), with what they need beside them (such
|
|
64
|
+
as @restatedev/agents' `signals`, which each agent brings with it).
|
|
65
|
+
`RESTATE_SERVE_ONLY=a,b` serves only the services it names: one program,
|
|
66
|
+
deployed in parts. For anything else (another port, HTTP/1.1, a
|
|
67
|
+
Lambda handler), the SDK's `restate.endpoint()` is there as ever.
|
|
68
|
+
|
|
62
69
|
### The contexts
|
|
63
70
|
|
|
64
71
|
The contexts are small and explicit, and a new one is built for each
|
|
@@ -238,11 +245,39 @@ started once the first attempt's cancel took effect. Get the id from a call
|
|
|
238
245
|
with an idempotency key instead, which gives every attempt the same answer
|
|
239
246
|
([calls and sends](#calls-and-sends)).
|
|
240
247
|
|
|
241
|
-
A cancellation
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
the
|
|
248
|
+
A cancellation reaches a handler as Restate's reaches any handler: once, at
|
|
249
|
+
the awaits pending when it comes, which fail with a `CancelledError`. The
|
|
250
|
+
session adds nothing to it. A `ctx.db` call is one such await: the request
|
|
251
|
+
of its own to Restate that a cancellation reaches (a read, or the sync a
|
|
252
|
+
commit waits for) fails, and so does the call. What the call sent to Restate
|
|
253
|
+
before that await stays: a commit's writes, and its transaction's sends,
|
|
254
|
+
which are made right after the writes, before the commit waits for anything.
|
|
255
|
+
So a `CancelledError` from `transaction()` doesn't say whether it committed,
|
|
256
|
+
as no cancelled await does: the database does. If it committed, its sends
|
|
257
|
+
are made, once.
|
|
258
|
+
|
|
259
|
+
The calls after it work: the next opens the session again, and reads what
|
|
260
|
+
is stored. So a handler can check what committed, and compensate:
|
|
261
|
+
|
|
262
|
+
```ts
|
|
263
|
+
try {
|
|
264
|
+
await ctx.db.transaction(async (tx) => {
|
|
265
|
+
/* ... */
|
|
266
|
+
});
|
|
267
|
+
} catch (e) {
|
|
268
|
+
if (!(e instanceof restate.CancelledError)) throw e;
|
|
269
|
+
await ctx.db.execute('UPDATE orders SET status = ? WHERE id = ?', ['cancelled', id]);
|
|
270
|
+
throw e;
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
A transaction whose body awaits something else (a `ctx.rpc`) that a
|
|
275
|
+
cancellation reaches fails with it and rolls back, unless the body catches
|
|
276
|
+
it. A retry of a cancelled invocation, after a crash, gets the cancellation
|
|
277
|
+
at its first await, which may be the open that makes what the crash left in
|
|
278
|
+
the outbox. No attempt follows a cancelled one, so as an attempt ends, a
|
|
279
|
+
session that a failure ended is opened again, which makes what the outbox
|
|
280
|
+
holds and empties it.
|
|
246
281
|
|
|
247
282
|
## Sends in a transaction
|
|
248
283
|
|
|
@@ -258,7 +293,9 @@ ctx.db.transaction(async (tx) => {
|
|
|
258
293
|
```
|
|
259
294
|
|
|
260
295
|
The sends are stored in the transaction's commit, in a record called
|
|
261
|
-
`outbox` next to the tables.
|
|
296
|
+
`outbox` next to the tables. The attempt makes them right after the
|
|
297
|
+
commit's writes, before it waits for them to be stored (Restate stores an
|
|
298
|
+
attempt's commands in order, so they are stored only if the commit is), each
|
|
262
299
|
with the idempotency key `transaction/<id>/<index>` (or the send's own key),
|
|
263
300
|
where `<id>` is a random id of the transaction. Then, before `transaction()`
|
|
264
301
|
resolves, a second commit empties the outbox. Restate stores an attempt's
|
|
@@ -466,10 +503,19 @@ in-memory copy of the object's state, through crashes and fencing.
|
|
|
466
503
|
- `contextOf`: a handler's or view's context over such a context;
|
|
467
504
|
- `Attempt` and `withAttempt`: an attempt's database;
|
|
468
505
|
- `open` and `asDatabase`: a database over a store of your own;
|
|
469
|
-
- `
|
|
506
|
+
- `withStoreWrapper`: fault injection in a session object's store;
|
|
507
|
+
- `configOf`: what a session object's attempts get, for attempts of a test's own.
|
|
470
508
|
|
|
471
509
|
It also has what this repository's other libraries need: `Schema` (tables a
|
|
472
510
|
library owns, applied where it uses them), `database` (another database of
|
|
473
511
|
the same key), `reset` (empty the key's database in a transaction), and
|
|
474
512
|
`cancelled` and `cancelCalls` (explicit cancellation, for a handler with
|
|
475
|
-
`explicitCancellation: true`)
|
|
513
|
+
`explicitCancellation: true`), and `ScopeKey` and `definitionOf`, for what a
|
|
514
|
+
library keeps for an attempt or for an object.
|
|
515
|
+
|
|
516
|
+
Nothing is kept per process, but the native page cache. Each attempt has a
|
|
517
|
+
scope, which its context holds: what code keeps for the attempt (an agent's
|
|
518
|
+
turn, say) is in it, by a `ScopeKey`, and ends with the attempt. What a
|
|
519
|
+
session object is given (its schema, its store's wrapper) is on its
|
|
520
|
+
definition, and a database or transaction this package makes holds its own
|
|
521
|
+
link to its session.
|
package/dist/database.d.ts
CHANGED
|
@@ -91,13 +91,39 @@ type Answer<T> = T | Promise<T>;
|
|
|
91
91
|
export declare function open(namespace: string, store: Store, { reader }?: {
|
|
92
92
|
reader?: boolean | undefined;
|
|
93
93
|
}): Promise<Connection>;
|
|
94
|
+
/**
|
|
95
|
+
* The store as the addon calls it. An error of the store's crosses the addon
|
|
96
|
+
* as text, which ends the session: the first is kept here, and the calls that
|
|
97
|
+
* fail on the session it ended fail with it as it was thrown (the SDK's
|
|
98
|
+
* CancelledError, say). And a commit's sync first runs what its transaction
|
|
99
|
+
* gave {@link ConnectionTransaction.withCommit}: after the commit's writes,
|
|
100
|
+
* before anything is awaited.
|
|
101
|
+
*/
|
|
102
|
+
declare class Boundary implements Store {
|
|
103
|
+
/** The first error of the store's. */
|
|
104
|
+
failed: {
|
|
105
|
+
error: unknown;
|
|
106
|
+
} | undefined;
|
|
107
|
+
/** What the next sync runs first: the committing transaction's. */
|
|
108
|
+
withSync: (() => void) | undefined;
|
|
109
|
+
readonly keys?: () => Promise<string[]>;
|
|
110
|
+
private readonly store;
|
|
111
|
+
constructor(store: Store);
|
|
112
|
+
get(key: string): Promise<Uint8Array<ArrayBufferLike> | null | undefined>;
|
|
113
|
+
set(key: string, value: Uint8Array): void;
|
|
114
|
+
clear(key: string): void;
|
|
115
|
+
sync(): Promise<void>;
|
|
116
|
+
/** `request`'s result, keeping its error, thrown at once or rejected. */
|
|
117
|
+
private kept;
|
|
118
|
+
}
|
|
94
119
|
/**
|
|
95
120
|
* SQL on a session of the addon: {@link DatabaseWriter}'s `query` and `execute`
|
|
96
121
|
* by way of its `queryColumns`.
|
|
97
122
|
*/
|
|
98
123
|
declare abstract class Sql implements DatabaseWriter {
|
|
99
124
|
protected readonly native: NativeSession;
|
|
100
|
-
|
|
125
|
+
protected readonly boundary: Boundary;
|
|
126
|
+
constructor(native: NativeSession, boundary: Boundary);
|
|
101
127
|
abstract queryColumns(sql: string, params?: SqlParam[]): Promise<SqlQueryResult>;
|
|
102
128
|
query<T = Row>(sql: string, params?: SqlParam[]): Promise<T[]>;
|
|
103
129
|
get<T = Row>(sql: string, params?: SqlParam[]): Promise<T | undefined>;
|
|
@@ -109,7 +135,10 @@ declare abstract class Sql implements DatabaseWriter {
|
|
|
109
135
|
* of a call that answers at once).
|
|
110
136
|
*/
|
|
111
137
|
protected request<T>(call: () => Answer<T>): Promise<T>;
|
|
112
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* A request's `error`: an {@link SqlError} if a retry would repeat it; the
|
|
140
|
+
* store's own error if that ended the session.
|
|
141
|
+
*/
|
|
113
142
|
protected failure(error: unknown): unknown;
|
|
114
143
|
}
|
|
115
144
|
/**
|
|
@@ -119,6 +148,8 @@ declare abstract class Sql implements DatabaseWriter {
|
|
|
119
148
|
* as it would wait for that body: the body uses its `tx`.
|
|
120
149
|
*/
|
|
121
150
|
export declare class Connection extends Sql {
|
|
151
|
+
/** This session's transaction whose body is running, in that body's asynchronous context. */
|
|
152
|
+
private readonly running;
|
|
122
153
|
/** Settles once the last call queued so far has: the next call runs after it. */
|
|
123
154
|
private queue;
|
|
124
155
|
queryColumns(sql: string, params?: SqlParam[]): Promise<SqlQueryResult>;
|
|
@@ -164,6 +195,14 @@ export interface ConnectionTransaction extends DatabaseWriter {
|
|
|
164
195
|
setRecord(name: string, value: Uint8Array): void;
|
|
165
196
|
/** The record `name` as this transaction would commit it: as it set it, or as committed. */
|
|
166
197
|
record(name: string): Promise<Uint8Array>;
|
|
198
|
+
/**
|
|
199
|
+
* Run `run` with the commit, right after its writes and before it waits
|
|
200
|
+
* for them to be stored: the store's host gets what `run` makes after the
|
|
201
|
+
* writes, and before anything that fails the commit's wait (Restate's
|
|
202
|
+
* sends, which it stores in order with the writes). Never if the
|
|
203
|
+
* transaction rolls back.
|
|
204
|
+
*/
|
|
205
|
+
withCommit(run: () => void): void;
|
|
167
206
|
}
|
|
168
207
|
export {};
|
|
169
208
|
//# sourceMappingURL=database.d.ts.map
|
package/dist/database.d.ts.map
CHANGED
|
@@ -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;IAC7B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACxB,IAAI,SAAc;CAC5B;AAED,0CAA0C;AAC1C,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE3C,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/D,yEA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GAAG,IAAI,CAAC;CACnC"}
|
package/dist/database.js
CHANGED
|
@@ -68,7 +68,67 @@ function load() {
|
|
|
68
68
|
* shared handler), the state as of open, and writes nothing.
|
|
69
69
|
*/
|
|
70
70
|
export async function open(namespace, store, { reader = false } = {}) {
|
|
71
|
-
|
|
71
|
+
const boundary = new Boundary(store);
|
|
72
|
+
try {
|
|
73
|
+
return new Connection(await addon.open(namespace, boundary, reader), boundary);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
throw boundary.failed?.error ?? error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The store as the addon calls it. An error of the store's crosses the addon
|
|
81
|
+
* as text, which ends the session: the first is kept here, and the calls that
|
|
82
|
+
* fail on the session it ended fail with it as it was thrown (the SDK's
|
|
83
|
+
* CancelledError, say). And a commit's sync first runs what its transaction
|
|
84
|
+
* gave {@link ConnectionTransaction.withCommit}: after the commit's writes,
|
|
85
|
+
* before anything is awaited.
|
|
86
|
+
*/
|
|
87
|
+
class Boundary {
|
|
88
|
+
/** The first error of the store's. */
|
|
89
|
+
failed;
|
|
90
|
+
/** What the next sync runs first: the committing transaction's. */
|
|
91
|
+
withSync;
|
|
92
|
+
keys;
|
|
93
|
+
store;
|
|
94
|
+
constructor(store) {
|
|
95
|
+
this.store = store;
|
|
96
|
+
// A store without keys keeps its garbage (see `Store.keys`).
|
|
97
|
+
const keys = store.keys?.bind(store);
|
|
98
|
+
if (keys)
|
|
99
|
+
this.keys = () => this.kept(keys);
|
|
100
|
+
}
|
|
101
|
+
get(key) {
|
|
102
|
+
return this.kept(() => this.store.get(key));
|
|
103
|
+
}
|
|
104
|
+
set(key, value) {
|
|
105
|
+
this.kept(() => this.store.set(key, value));
|
|
106
|
+
}
|
|
107
|
+
clear(key) {
|
|
108
|
+
this.kept(() => this.store.clear(key));
|
|
109
|
+
}
|
|
110
|
+
sync() {
|
|
111
|
+
return this.kept(() => {
|
|
112
|
+
const run = this.withSync;
|
|
113
|
+
this.withSync = undefined;
|
|
114
|
+
run?.();
|
|
115
|
+
return this.store.sync();
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/** `request`'s result, keeping its error, thrown at once or rejected. */
|
|
119
|
+
kept(request) {
|
|
120
|
+
const keep = (error) => {
|
|
121
|
+
this.failed ??= { error };
|
|
122
|
+
throw error;
|
|
123
|
+
};
|
|
124
|
+
try {
|
|
125
|
+
const result = request();
|
|
126
|
+
return (result instanceof Promise ? result.catch(keep) : result);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
return keep(error);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
72
132
|
}
|
|
73
133
|
/**
|
|
74
134
|
* SQL on a session of the addon: {@link DatabaseWriter}'s `query` and `execute`
|
|
@@ -76,8 +136,10 @@ export async function open(namespace, store, { reader = false } = {}) {
|
|
|
76
136
|
*/
|
|
77
137
|
class Sql {
|
|
78
138
|
native;
|
|
79
|
-
|
|
139
|
+
boundary;
|
|
140
|
+
constructor(native, boundary) {
|
|
80
141
|
this.native = native;
|
|
142
|
+
this.boundary = boundary;
|
|
81
143
|
}
|
|
82
144
|
query(sql, params) {
|
|
83
145
|
return sqlOver((s, p) => this.queryColumns(s, p)).query(sql, params);
|
|
@@ -104,10 +166,16 @@ class Sql {
|
|
|
104
166
|
throw this.failure(error);
|
|
105
167
|
}
|
|
106
168
|
}
|
|
107
|
-
/**
|
|
169
|
+
/**
|
|
170
|
+
* A request's `error`: an {@link SqlError} if a retry would repeat it; the
|
|
171
|
+
* store's own error if that ended the session.
|
|
172
|
+
*/
|
|
108
173
|
failure(error) {
|
|
109
174
|
if (error instanceof SqlError)
|
|
110
175
|
return error;
|
|
176
|
+
const failed = this.boundary.failed;
|
|
177
|
+
if (failed !== undefined && !this.native.isUsable())
|
|
178
|
+
return failed.error;
|
|
111
179
|
const repeats = error.code === REFUSED || this.native.isUsable();
|
|
112
180
|
return repeats ? new SqlError(error.message, { cause: error }) : error;
|
|
113
181
|
}
|
|
@@ -115,9 +183,6 @@ class Sql {
|
|
|
115
183
|
// The code of the addon's errors that a retry would repeat even though they
|
|
116
184
|
// ended the session (its `Refused`), and of arguments it cannot convert.
|
|
117
185
|
const REFUSED = 'InvalidArg';
|
|
118
|
-
// The transaction whose body is running, in that body's asynchronous context:
|
|
119
|
-
// the innermost, which knows the ones it runs inside.
|
|
120
|
-
const running = new AsyncLocalStorage();
|
|
121
186
|
/**
|
|
122
187
|
* A session of a database: calls run one at a time, in call order, and a
|
|
123
188
|
* transaction holds the session until it commits or rolls back. Calls made
|
|
@@ -125,6 +190,8 @@ const running = new AsyncLocalStorage();
|
|
|
125
190
|
* as it would wait for that body: the body uses its `tx`.
|
|
126
191
|
*/
|
|
127
192
|
export class Connection extends Sql {
|
|
193
|
+
/** This session's transaction whose body is running, in that body's asynchronous context. */
|
|
194
|
+
running = new AsyncLocalStorage();
|
|
128
195
|
/** Settles once the last call queued so far has: the next call runs after it. */
|
|
129
196
|
queue = Promise.resolve();
|
|
130
197
|
queryColumns(sql, params) {
|
|
@@ -140,10 +207,10 @@ export class Connection extends Sql {
|
|
|
140
207
|
transaction(body) {
|
|
141
208
|
return this.serial(async () => {
|
|
142
209
|
await this.request(() => this.native.begin());
|
|
143
|
-
const tx = new OpenTransaction(this
|
|
210
|
+
const tx = new OpenTransaction(this.native, this.boundary);
|
|
144
211
|
let result;
|
|
145
212
|
try {
|
|
146
|
-
result = await running.run(tx, () => body(tx));
|
|
213
|
+
result = await this.running.run(tx, () => body(tx));
|
|
147
214
|
}
|
|
148
215
|
catch (error) {
|
|
149
216
|
await tx.end();
|
|
@@ -151,6 +218,10 @@ export class Connection extends Sql {
|
|
|
151
218
|
throw error;
|
|
152
219
|
}
|
|
153
220
|
const records = await tx.end();
|
|
221
|
+
// Its commit's sync runs what the body gave `withCommit`; one that
|
|
222
|
+
// wrote nothing synced nothing, and it runs after.
|
|
223
|
+
this.boundary.withSync = tx.commitRuns();
|
|
224
|
+
let unsynced;
|
|
154
225
|
try {
|
|
155
226
|
await this.native.commit(records);
|
|
156
227
|
}
|
|
@@ -160,6 +231,11 @@ export class Connection extends Sql {
|
|
|
160
231
|
await this.rollback();
|
|
161
232
|
throw this.failure(error);
|
|
162
233
|
}
|
|
234
|
+
finally {
|
|
235
|
+
unsynced = this.boundary.withSync;
|
|
236
|
+
this.boundary.withSync = undefined;
|
|
237
|
+
}
|
|
238
|
+
unsynced?.();
|
|
163
239
|
return result;
|
|
164
240
|
});
|
|
165
241
|
}
|
|
@@ -188,7 +264,7 @@ export class Connection extends Sql {
|
|
|
188
264
|
}
|
|
189
265
|
/** Run `call` once the calls before it have, unless it comes from the body of a transaction it would wait for. */
|
|
190
266
|
serial(call) {
|
|
191
|
-
if (running.getStore()?.
|
|
267
|
+
if (this.running.getStore()?.open) {
|
|
192
268
|
return Promise.reject(new SqlError('inside a transaction, use the transaction handle its body gets'));
|
|
193
269
|
}
|
|
194
270
|
const result = this.queue.then(call);
|
|
@@ -210,22 +286,16 @@ export class Connection extends Sql {
|
|
|
210
286
|
* before its commit or rollback, so none outlives it.
|
|
211
287
|
*/
|
|
212
288
|
class OpenTransaction extends Sql {
|
|
213
|
-
database;
|
|
214
|
-
/** The transaction whose body this one's runs in, if any: of another database, since a database's own are refused. */
|
|
215
|
-
outer;
|
|
216
289
|
/** The records it sets, by name. */
|
|
217
290
|
records = new Map();
|
|
291
|
+
/** What runs with its commit (`withCommit`). */
|
|
292
|
+
withCommits = [];
|
|
218
293
|
/** Settles once the last call queued so far has: the next call runs after it. */
|
|
219
294
|
queue = Promise.resolve();
|
|
220
295
|
ended = false;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
this.
|
|
224
|
-
this.outer = outer;
|
|
225
|
-
}
|
|
226
|
-
/** Whether this transaction, or one it runs inside, is open and holds `database`. */
|
|
227
|
-
holds(database) {
|
|
228
|
-
return (!this.ended && this.database === database) || (this.outer?.holds(database) ?? false);
|
|
296
|
+
/** Whether it is open: its body runs, and holds its session. */
|
|
297
|
+
get open() {
|
|
298
|
+
return !this.ended;
|
|
229
299
|
}
|
|
230
300
|
/**
|
|
231
301
|
* End it, refusing calls from now on, once the calls made before have
|
|
@@ -243,6 +313,15 @@ class OpenTransaction extends Sql {
|
|
|
243
313
|
this.refuseEnded();
|
|
244
314
|
this.records.set(name, Buffer.from(value));
|
|
245
315
|
}
|
|
316
|
+
withCommit(run) {
|
|
317
|
+
this.refuseEnded();
|
|
318
|
+
this.withCommits.push(run);
|
|
319
|
+
}
|
|
320
|
+
/** What runs with its commit, once it ended: see {@link withCommit}. */
|
|
321
|
+
commitRuns() {
|
|
322
|
+
const runs = this.withCommits;
|
|
323
|
+
return runs.length === 0 ? undefined : () => runs.forEach((run) => run());
|
|
324
|
+
}
|
|
246
325
|
record(name) {
|
|
247
326
|
// As set when it is called, in call order with `setRecord`.
|
|
248
327
|
const set = this.records.get(name);
|
package/dist/database.js.map
CHANGED
|
@@ -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,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAcpD;;;;;;;GAOG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,GAAG,UAAU,CAAC;CAC5B;AA2BD,kGAAkG;AAClG,SAAS,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAkB;IAChD,IAAI,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,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C,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACpC,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,WAAW;QACjB,IAAI,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,QAAQ,CAAC,2BAA2B,CAAC,CAAC;IAClE,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export type { Database, DatabaseReader, DatabaseWriter, Row, SqlParam, SqlValue,
|
|
|
3
3
|
export type { Step } from './schema.ts';
|
|
4
4
|
export { sessionObject, type Cancel, type Entry, type HandlerOptions, type SessionContext, type ViewContext, } from './object.ts';
|
|
5
5
|
export type { CallOptions, Client, Rpc, Send, SendClient, SendOptions, Target } from './calls.ts';
|
|
6
|
+
export { serve } from './serve.ts';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwBA,cAAc,yBAAyB,CAAC;AACxC,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACnH,YAAY,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,aAAa,EACb,KAAK,MAAM,EACX,KAAK,KAAK,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAElG,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,10 @@
|
|
|
19
19
|
//
|
|
20
20
|
// See README.md.
|
|
21
21
|
// The SDK, and what this module adds to it (or declares in its place: its
|
|
22
|
-
// `Client`, `SendClient` and `Target` are a session object's
|
|
22
|
+
// `Client`, `SendClient` and `Target` are a session object's, and `serve`
|
|
23
|
+
// takes the services, with what they need beside them).
|
|
23
24
|
export * from '@restatedev/restate-sdk';
|
|
24
25
|
export { sessionObject, } from './object.js';
|
|
26
|
+
// In place of the SDK's: the services, on PORT, with what they need beside them.
|
|
27
|
+
export { serve } from './serve.js';
|
|
25
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,0EAA0E;AAC1E,mCAAmC;AACnC,EAAE;AACF,qDAAqD;AACrD,EAAE;AACF,0CAA0C;AAC1C,qBAAqB;AACrB,2DAA2D;AAC3D,kBAAkB;AAClB,4CAA4C;AAC5C,+EAA+E;AAC/E,WAAW;AACX,SAAS;AACT,eAAe;AACf,uFAAuF;AACvF,SAAS;AACT,QAAQ;AACR,EAAE;AACF,iBAAiB;AAEjB,0EAA0E;AAC1E
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,0EAA0E;AAC1E,mCAAmC;AACnC,EAAE;AACF,qDAAqD;AACrD,EAAE;AACF,0CAA0C;AAC1C,qBAAqB;AACrB,2DAA2D;AAC3D,kBAAkB;AAClB,4CAA4C;AAC5C,+EAA+E;AAC/E,WAAW;AACX,SAAS;AACT,eAAe;AACf,uFAAuF;AACvF,SAAS;AACT,QAAQ;AACR,EAAE;AACF,iBAAiB;AAEjB,0EAA0E;AAC1E,0EAA0E;AAC1E,wDAAwD;AACxD,cAAc,yBAAyB,CAAC;AAGxC,OAAO,EACL,aAAa,GAMd,MAAM,aAAa,CAAC;AAErB,iFAAiF;AACjF,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export * as sdk from '@restatedev/restate-sdk';
|
|
2
2
|
export { Schema } from './schema.ts';
|
|
3
|
-
export { asDatabase, lazyDatabase, database, reset,
|
|
4
|
-
export type { SqlHost } from './session.ts';
|
|
3
|
+
export { asDatabase, lazyDatabase, database, reset, Attempt, withAttempt } from './session.ts';
|
|
4
|
+
export type { ObjectConfig, SqlHost } from './session.ts';
|
|
5
|
+
export { Link } from './link.ts';
|
|
6
|
+
export { ScopeKey } from './scope.ts';
|
|
5
7
|
export { open, type Connection, type Store, type ConnectionTransaction } from './database.ts';
|
|
6
8
|
export { PromiseSelector } from './selector.ts';
|
|
7
|
-
export {
|
|
9
|
+
export { needing, served } from './serve.ts';
|
|
10
|
+
export { cancelCalls, cancelled, configOf, contextOf, definitionOf, HEAD_KEY, invoke, withStoreWrapper, type AttemptContext, } from './object.ts';
|
|
8
11
|
export type { DoProgressResult, Selectable, UnresolvedFuture } from './selector.ts';
|
|
9
12
|
//# sourceMappingURL=internal.d.ts.map
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/F,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,KAAK,KAAK,EAAE,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EACL,WAAW,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,gBAAgB,EAChB,KAAK,cAAc,GACpB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/internal.js
CHANGED
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
// own copy, so that a library's journaled handlers serve beside its objects).
|
|
6
6
|
export * as sdk from '@restatedev/restate-sdk';
|
|
7
7
|
export { Schema } from './schema.js';
|
|
8
|
-
export { asDatabase, lazyDatabase, database, reset,
|
|
8
|
+
export { asDatabase, lazyDatabase, database, reset, Attempt, withAttempt } from './session.js';
|
|
9
|
+
export { Link } from './link.js';
|
|
10
|
+
export { ScopeKey } from './scope.js';
|
|
9
11
|
export { open } from './database.js';
|
|
10
12
|
export { PromiseSelector } from './selector.js';
|
|
11
|
-
export {
|
|
13
|
+
export { needing, served } from './serve.js';
|
|
14
|
+
export { cancelCalls, cancelled, configOf, contextOf, definitionOf, HEAD_KEY, invoke, withStoreWrapper, } from './object.js';
|
|
12
15
|
//# sourceMappingURL=internal.js.map
|
package/dist/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,mFAAmF;AACnF,8EAA8E;AAC9E,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,mFAAmF;AACnF,8EAA8E;AAC9E,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE/F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,IAAI,EAA2D,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EACL,WAAW,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,gBAAgB,GAEjB,MAAM,aAAa,CAAC"}
|
package/dist/link.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A link of one kind, on the objects that have one. */
|
|
2
|
+
export declare class Link<T> {
|
|
3
|
+
private readonly key;
|
|
4
|
+
constructor(what: string);
|
|
5
|
+
/** `owner`, linked to `value`: once, as it is made (before it is frozen). */
|
|
6
|
+
on<O extends object>(owner: O, value: T): O;
|
|
7
|
+
/** What `owner` is linked to, if it has this link. */
|
|
8
|
+
of(owner: object): T | undefined;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAIA,wDAAwD;AACxD,qBAAa,IAAI,CAAC,CAAC;IACjB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAE7B,YAAY,IAAI,EAAE,MAAM,EAEvB;IAED,6EAA6E;IAC7E,EAAE,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAE1C;IAED,sDAAsD;IACtD,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAE/B;CACF"}
|
package/dist/link.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// A private link on the objects this code makes: set once, as it makes one,
|
|
2
|
+
// and read by its code alone (a database's session, a transaction's reset, a
|
|
3
|
+
// definition's own). Not enumerable, so the object reads as its fields alone.
|
|
4
|
+
/** A link of one kind, on the objects that have one. */
|
|
5
|
+
export class Link {
|
|
6
|
+
key;
|
|
7
|
+
constructor(what) {
|
|
8
|
+
this.key = Symbol(what);
|
|
9
|
+
}
|
|
10
|
+
/** `owner`, linked to `value`: once, as it is made (before it is frozen). */
|
|
11
|
+
on(owner, value) {
|
|
12
|
+
return Object.defineProperty(owner, this.key, { value });
|
|
13
|
+
}
|
|
14
|
+
/** What `owner` is linked to, if it has this link. */
|
|
15
|
+
of(owner) {
|
|
16
|
+
return owner[this.key];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=link.js.map
|
package/dist/link.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAE9E,wDAAwD;AACxD,MAAM,OAAO,IAAI;IACE,GAAG,CAAS;IAE7B,YAAY,IAAY;QACtB,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,6EAA6E;IAC7E,EAAE,CAAmB,KAAQ,EAAE,KAAQ;QACrC,OAAO,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,sDAAsD;IACtD,EAAE,CAAC,KAAa;QACd,OAAQ,KAAuC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
package/dist/object.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as restate from '@restatedev/restate-sdk';
|
|
2
2
|
import type { VirtualObjectDefinition } from '@restatedev/restate-sdk-core';
|
|
3
3
|
import { type Rpc, type Send } from './calls.ts';
|
|
4
|
-
import type { DatabaseReader } from './database.ts';
|
|
4
|
+
import type { DatabaseReader, Store } from './database.ts';
|
|
5
5
|
import { type Step } from './schema.ts';
|
|
6
|
-
import { type Database, type SqlHost } from './session.ts';
|
|
6
|
+
import { type Database, type ObjectConfig, type SqlHost } from './session.ts';
|
|
7
7
|
/**
|
|
8
8
|
* The context of a session object's handler. A handler runs in attempts:
|
|
9
9
|
* Restate starts a new one after a crash, a retryable error or a
|
|
@@ -101,8 +101,19 @@ type Runtime = {
|
|
|
101
101
|
export type AttemptContext = Pick<restate.ObjectContext, 'key' | 'request' | 'get' | 'set' | 'clear' | 'stateKeys' | 'run' | 'genericSend' | 'genericCall' | 'invocation'> & Runtime;
|
|
102
102
|
/** What an attempt's session needs of the SDK's context `ctx`. */
|
|
103
103
|
export declare function host(ctx: restate.ObjectContext | restate.ObjectSharedContext | AttemptContext, shared: boolean): SqlHost;
|
|
104
|
-
/**
|
|
105
|
-
|
|
104
|
+
/**
|
|
105
|
+
* The definition (`sessionObject`'s) of the object whose handler or view
|
|
106
|
+
* `ctx` is the context of: what a library keeps per object lives on it.
|
|
107
|
+
*/
|
|
108
|
+
export declare const definitionOf: (ctx: SessionContext | ViewContext) => object | undefined;
|
|
109
|
+
/** What `definition`'s attempts get, if it is a session object: for a test's attempts of its own. */
|
|
110
|
+
export declare const configOf: (definition: object) => ObjectConfig | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Wrap the stores of `definition`'s attempts with `wrap`: fault injection, in
|
|
113
|
+
* tests. A definition that is no session object has no store: it is left as
|
|
114
|
+
* it is.
|
|
115
|
+
*/
|
|
116
|
+
export declare function withStoreWrapper<D extends object>(definition: D, wrapper: (store: Store) => Store): D;
|
|
106
117
|
/**
|
|
107
118
|
* The context of a handler (or, with `view`, of a view) over the SDK's
|
|
108
119
|
* context `ctx`, with the database `db`: what an attempt gets, and a test's
|
|
@@ -111,10 +122,12 @@ export declare const sdkContexts: WeakMap<SessionContext | ViewContext, restate.
|
|
|
111
122
|
*/
|
|
112
123
|
export declare function contextOf(ctx: AttemptContext, db: Database, options: {
|
|
113
124
|
view: true;
|
|
125
|
+
definition?: object;
|
|
114
126
|
}): ViewContext;
|
|
115
127
|
export declare function contextOf(ctx: AttemptContext, db: Database, options?: {
|
|
116
128
|
view?: false;
|
|
117
129
|
explicitCancellation?: boolean;
|
|
130
|
+
definition?: object;
|
|
118
131
|
}): SessionContext;
|
|
119
132
|
/**
|
|
120
133
|
* Run handler or view `name` of `definition` for one attempt over `ctx`, a
|
package/dist/object.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":"AAiBA,OAAO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