@restatedev/restate-sdk 0.7.0 → 0.7.1-worker

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 (88) hide show
  1. package/dist/cloudflare_bundle.js +27387 -0
  2. package/dist/io/encoder.d.ts +2 -1
  3. package/dist/io/encoder.d.ts.map +1 -1
  4. package/package.json +7 -3
  5. package/dist/connection/buffered_connection.js +0 -44
  6. package/dist/connection/buffered_connection.js.map +0 -1
  7. package/dist/connection/connection.js +0 -13
  8. package/dist/connection/connection.js.map +0 -1
  9. package/dist/connection/embedded_connection.js +0 -59
  10. package/dist/connection/embedded_connection.js.map +0 -1
  11. package/dist/connection/http_connection.js +0 -203
  12. package/dist/connection/http_connection.js.map +0 -1
  13. package/dist/connection/lambda_connection.js +0 -58
  14. package/dist/connection/lambda_connection.js.map +0 -1
  15. package/dist/embedded/api.js +0 -35
  16. package/dist/embedded/api.js.map +0 -1
  17. package/dist/embedded/handler.js +0 -28
  18. package/dist/embedded/handler.js.map +0 -1
  19. package/dist/embedded/http2_remote.js +0 -91
  20. package/dist/embedded/http2_remote.js.map +0 -1
  21. package/dist/embedded/invocation.js +0 -94
  22. package/dist/embedded/invocation.js.map +0 -1
  23. package/dist/generated/dev/restate/events.js +0 -371
  24. package/dist/generated/dev/restate/events.js.map +0 -1
  25. package/dist/generated/dev/restate/ext.js +0 -215
  26. package/dist/generated/dev/restate/ext.js.map +0 -1
  27. package/dist/generated/google/protobuf/descriptor.js +0 -6676
  28. package/dist/generated/google/protobuf/descriptor.js.map +0 -1
  29. package/dist/generated/google/protobuf/empty.js +0 -107
  30. package/dist/generated/google/protobuf/empty.js.map +0 -1
  31. package/dist/generated/google/protobuf/struct.js +0 -754
  32. package/dist/generated/google/protobuf/struct.js.map +0 -1
  33. package/dist/generated/proto/discovery.js +0 -364
  34. package/dist/generated/proto/discovery.js.map +0 -1
  35. package/dist/generated/proto/dynrpc.js +0 -668
  36. package/dist/generated/proto/dynrpc.js.map +0 -1
  37. package/dist/generated/proto/javascript.js +0 -297
  38. package/dist/generated/proto/javascript.js.map +0 -1
  39. package/dist/generated/proto/protocol.js +0 -2398
  40. package/dist/generated/proto/protocol.js.map +0 -1
  41. package/dist/generated/proto/services.js +0 -1535
  42. package/dist/generated/proto/services.js.map +0 -1
  43. package/dist/generated/proto/test.js +0 -321
  44. package/dist/generated/proto/test.js.map +0 -1
  45. package/dist/invocation.js +0 -154
  46. package/dist/invocation.js.map +0 -1
  47. package/dist/io/decoder.js +0 -133
  48. package/dist/io/decoder.js.map +0 -1
  49. package/dist/io/encoder.js +0 -68
  50. package/dist/io/encoder.js.map +0 -1
  51. package/dist/journal.js +0 -372
  52. package/dist/journal.js.map +0 -1
  53. package/dist/local_state_store.js +0 -72
  54. package/dist/local_state_store.js.map +0 -1
  55. package/dist/public_api.js +0 -58
  56. package/dist/public_api.js.map +0 -1
  57. package/dist/restate_context.js +0 -46
  58. package/dist/restate_context.js.map +0 -1
  59. package/dist/restate_context_impl.js +0 -375
  60. package/dist/restate_context_impl.js.map +0 -1
  61. package/dist/server/base_restate_server.js +0 -364
  62. package/dist/server/base_restate_server.js.map +0 -1
  63. package/dist/server/restate_lambda_handler.js +0 -247
  64. package/dist/server/restate_lambda_handler.js.map +0 -1
  65. package/dist/server/restate_server.js +0 -186
  66. package/dist/server/restate_server.js.map +0 -1
  67. package/dist/state_machine.js +0 -403
  68. package/dist/state_machine.js.map +0 -1
  69. package/dist/types/errors.js +0 -267
  70. package/dist/types/errors.js.map +0 -1
  71. package/dist/types/grpc.js +0 -68
  72. package/dist/types/grpc.js.map +0 -1
  73. package/dist/types/protocol.js +0 -125
  74. package/dist/types/protocol.js.map +0 -1
  75. package/dist/types/router.js +0 -36
  76. package/dist/types/router.js.map +0 -1
  77. package/dist/types/types.js +0 -126
  78. package/dist/types/types.js.map +0 -1
  79. package/dist/utils/assumpsions.js +0 -101
  80. package/dist/utils/assumpsions.js.map +0 -1
  81. package/dist/utils/logger.js +0 -102
  82. package/dist/utils/logger.js.map +0 -1
  83. package/dist/utils/public_utils.js +0 -49
  84. package/dist/utils/public_utils.js.map +0 -1
  85. package/dist/utils/rand.js +0 -114
  86. package/dist/utils/rand.js.map +0 -1
  87. package/dist/utils/utils.js +0 -144
  88. package/dist/utils/utils.js.map +0 -1
@@ -1,133 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
4
- *
5
- * This file is part of the Restate SDK for Node.js/TypeScript,
6
- * which is released under the MIT license.
7
- *
8
- * You can find a copy of the license in file LICENSE in the root
9
- * directory of this repository or package, or at
10
- * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
11
- */
12
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.decodeMessagesBuffer = exports.decodeLambdaBody = exports.streamDecoder = void 0;
17
- // This is a NodeJs stream transformer. It is used to convert a chunked stream of bytes to
18
- // a stream of JavaScript objects of the form { header: .. , message: ..} where:
19
- // * header has some information about the frame like, the message type, and some flags.
20
- // * message is the Protobuf decoded message.
21
- //
22
- // To use this one would need to do the following:
23
- //
24
- // let decodedStream = stream.pipe(streamDecoder());
25
- //
26
- // at this point the decodedStream is a high level stream of objects {header, message}
27
- const stream_1 = __importDefault(require("stream"));
28
- const protocol_1 = require("../types/protocol");
29
- const types_1 = require("../types/types");
30
- const assert_1 = __importDefault(require("assert"));
31
- const errors_1 = require("../types/errors");
32
- const WAITING_FOR_HEADER = 0;
33
- const WAITING_FOR_BODY = 1;
34
- function initalDecoderState(buf) {
35
- return {
36
- state: WAITING_FOR_HEADER,
37
- header: undefined,
38
- buf,
39
- };
40
- }
41
- function appendBufferToDecoder(state, chunk) {
42
- state.buf = Buffer.concat([state.buf, chunk]);
43
- }
44
- function decodeMessages(decoderState, out) {
45
- let buf = decoderState.buf;
46
- while (buf.length > 0 || decoderState.state === WAITING_FOR_BODY) {
47
- switch (decoderState.state) {
48
- case WAITING_FOR_HEADER: {
49
- (0, assert_1.default)(decoderState.header === undefined);
50
- if (buf.length < 8) {
51
- decoderState.buf = buf;
52
- return decoderState;
53
- }
54
- const h = buf.readBigUInt64BE();
55
- buf = buf.subarray(8);
56
- decoderState.header = types_1.Header.fromU64be(h);
57
- decoderState.state = WAITING_FOR_BODY;
58
- break;
59
- }
60
- case WAITING_FOR_BODY: {
61
- const header = decoderState.header;
62
- (0, assert_1.default)(header !== undefined);
63
- if (buf.length < header.frameLength) {
64
- decoderState.buf = buf;
65
- return decoderState;
66
- }
67
- const frame = buf.subarray(0, header.frameLength);
68
- buf = buf.subarray(header.frameLength);
69
- decoderState.state = WAITING_FOR_HEADER;
70
- decoderState.header = undefined;
71
- const pbType = protocol_1.PROTOBUF_MESSAGE_BY_TYPE.get(header.messageType);
72
- if (pbType === undefined) {
73
- throw new Error("Got unknown message type " + header.messageType);
74
- }
75
- else {
76
- const message = pbType.decode(frame);
77
- out.push(new types_1.Message(header.messageType, message, header.completedFlag, header.protocolVersion, header.requiresAckFlag));
78
- }
79
- break;
80
- }
81
- }
82
- }
83
- decoderState.buf = buf;
84
- return decoderState;
85
- }
86
- function streamDecoder() {
87
- let decoderState = initalDecoderState(Buffer.alloc(0));
88
- return new stream_1.default.Transform({
89
- writableObjectMode: true,
90
- objectMode: true,
91
- transform(chunk, _encoding, cb) {
92
- try {
93
- appendBufferToDecoder(decoderState, chunk);
94
- decoderState = decodeMessages(decoderState, this);
95
- cb();
96
- }
97
- catch (e) {
98
- cb((0, errors_1.ensureError)(e), null);
99
- }
100
- },
101
- });
102
- }
103
- exports.streamDecoder = streamDecoder;
104
- // Decodes messages from Lambda requests to an array of headers + protocol messages
105
- const base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
106
- function decodeLambdaBody(msgBase64) {
107
- if (!base64regex.test(msgBase64)) {
108
- throw new Error("Cannot parse the lambda request body, body was not valid base64 encoded: " +
109
- msgBase64);
110
- }
111
- const buffer = Buffer.from(msgBase64, "base64");
112
- return decodeMessagesBuffer(buffer);
113
- }
114
- exports.decodeLambdaBody = decodeLambdaBody;
115
- function decodeMessagesBuffer(buffer) {
116
- const decodedEntries = [];
117
- let finalState;
118
- try {
119
- finalState = decodeMessages(initalDecoderState(buffer), decodedEntries);
120
- }
121
- catch (e) {
122
- const err = (0, errors_1.ensureError)(e);
123
- throw new Error("Cannot parse the lambda request body, message was not a valid sequence of Restate messages: " +
124
- err.message, { cause: err });
125
- }
126
- if (finalState.buf.length > 0) {
127
- throw new Error("Cannot parse the request body: Trailing data (incomplete message) in request body: " +
128
- finalState.buf.toString("hex"));
129
- }
130
- return decodedEntries;
131
- }
132
- exports.decodeMessagesBuffer = decodeMessagesBuffer;
133
- //# sourceMappingURL=decoder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decoder.js","sourceRoot":"","sources":["../../src/io/decoder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;AAEH,0FAA0F;AAC1F,gFAAgF;AAChF,wFAAwF;AACxF,6CAA6C;AAC7C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,oDAAoD;AACpD,EAAE;AACF,sFAAsF;AAEtF,oDAA4B;AAC5B,gDAA6D;AAC7D,0CAAiD;AACjD,oDAA4B;AAC5B,4CAA8C;AAK9C,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,SAAS,kBAAkB,CAAC,GAAW;IACrC,OAAO;QACL,KAAK,EAAE,kBAAkB;QACzB,MAAM,EAAE,SAAS;QACjB,GAAG;KACJ,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAmB,EAAE,KAAa;IAC/D,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CA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AI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAChC,MAAM,IAAI,KAAK,CACb,2EAA2E;YACzE,SAAS,CACZ,CAAC;KACH;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAChD,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AATD,4CASC;AAED,SAAgB,oBAAoB,CAAC,MAAc;IACjD,MAAM,cAAc,GAAc,EAAE,CAAC;IACrC,IAAI,UAAU,CAAC;IACf,IAAI;QACF,UAAU,GAAG,cAAc,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC;KACzE;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,GAAG,GAAG,IAAA,oBAAW,EAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,8FAA8F;YAC5F,GAAG,CAAC,OAAO,EACb,EAAE,KAAK,EAAE,GAAG,EAAE,CACf,CAAC;KACH;IAED,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE;QAC7B,MAAM,IAAI,KAAK,CACb,qFAAqF;YACnF,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CACjC,CAAC;KACH;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAtBD,oDAsBC"}
@@ -1,68 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
4
- *
5
- * This file is part of the Restate SDK for Node.js/TypeScript,
6
- * which is released under the MIT license.
7
- *
8
- * You can find a copy of the license in file LICENSE in the root
9
- * directory of this repository or package, or at
10
- * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
11
- */
12
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.encodeMessages = exports.encodeMessage = exports.streamEncoder = void 0;
17
- const stream_1 = __importDefault(require("stream"));
18
- const protocol_1 = require("../types/protocol");
19
- const types_1 = require("../types/types");
20
- const minimal_1 = __importDefault(require("protobufjs/minimal"));
21
- function streamEncoder() {
22
- return new stream_1.default.Transform({
23
- writableObjectMode: true,
24
- objectMode: true,
25
- transform(msg, _encoding, cb) {
26
- // We do not catch errors here because we want them to be handled at the Connection level,
27
- // so we can close the state machine.
28
- const result = encodeMessage(msg);
29
- cb(null, result);
30
- },
31
- });
32
- }
33
- exports.streamEncoder = streamEncoder;
34
- function encodeMessage(msg) {
35
- return encodeMessages([msg]);
36
- }
37
- exports.encodeMessage = encodeMessage;
38
- function encodeMessages(messages) {
39
- const offsets = [];
40
- const headers = [];
41
- let off = 0;
42
- const writer = minimal_1.default.Writer.create();
43
- for (const message of messages) {
44
- const pbType = protocol_1.PROTOBUF_MESSAGE_BY_TYPE.get(BigInt(message.messageType));
45
- if (pbType === undefined) {
46
- throw new Error("Trying to encode a message with unknown message type " +
47
- message.messageType);
48
- }
49
- offsets.push(off);
50
- writer.fixed64(0);
51
- pbType.encode(message.message, writer);
52
- const messageLen = writer.len - 8 - off;
53
- off = writer.len;
54
- const header = new types_1.Header(BigInt(message.messageType), messageLen, message.completed, message.protocolVersion, // only set for incoming start message
55
- message.requiresAck);
56
- const header64 = header.toU64be();
57
- headers.push(header64);
58
- }
59
- const buffer = writer.finish();
60
- for (let i = 0; i < offsets.length; i++) {
61
- const offset = offsets[i];
62
- const header = headers[i];
63
- buffer.writeBigUInt64BE(header, offset);
64
- }
65
- return buffer;
66
- }
67
- exports.encodeMessages = encodeMessages;
68
- //# sourceMappingURL=encoder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../src/io/encoder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;AAEH,oDAA4B;AAC5B,gDAA6D;AAC7D,0CAAiD;AACjD,iEAAqC;AAErC,SAA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cAAM,CACvB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAC3B,UAAU,EACV,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,eAAe,EAAE,sCAAsC;QAC/D,OAAO,CAAC,WAAW,CACpB,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KACxB;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAY,CAAC;IACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1B,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACzC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AArCD,wCAqCC"}
package/dist/journal.js DELETED
@@ -1,372 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
4
- *
5
- * This file is part of the Restate SDK for Node.js/TypeScript,
6
- * which is released under the MIT license.
7
- *
8
- * You can find a copy of the license in file LICENSE in the root
9
- * directory of this repository or package, or at
10
- * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
11
- */
12
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- var desc = Object.getOwnPropertyDescriptor(m, k);
15
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
- desc = { enumerable: true, get: function() { return m[k]; } };
17
- }
18
- Object.defineProperty(o, k2, desc);
19
- }) : (function(o, m, k, k2) {
20
- if (k2 === undefined) k2 = k;
21
- o[k2] = m[k];
22
- }));
23
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
- Object.defineProperty(o, "default", { enumerable: true, value: v });
25
- }) : function(o, v) {
26
- o["default"] = v;
27
- });
28
- var __importStar = (this && this.__importStar) || function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.NewExecutionState = exports.JournalEntry = exports.Journal = void 0;
37
- const p = __importStar(require("./types/protocol"));
38
- const protocol_1 = require("./types/protocol");
39
- const utils_1 = require("./utils/utils");
40
- const types_1 = require("./types/types");
41
- const errors_1 = require("./types/errors");
42
- const RESOLVED = Promise.resolve(undefined);
43
- class Journal {
44
- invocation;
45
- state = NewExecutionState.REPLAYING;
46
- userCodeJournalIndex = 0;
47
- // Journal entries waiting for arrival of runtime completion
48
- // 0 = root promise of the method invocation
49
- pendingJournalEntries = new Map();
50
- constructor(invocation) {
51
- this.invocation = invocation;
52
- const inputMessage = invocation.replayEntries.get(0);
53
- if (!inputMessage ||
54
- inputMessage.messageType !== protocol_1.POLL_INPUT_STREAM_ENTRY_MESSAGE_TYPE) {
55
- throw errors_1.RetryableError.protocolViolation("First message of replay entries needs to be PollInputStreamMessage");
56
- }
57
- this.handleInputMessage(inputMessage.message);
58
- }
59
- handleInputMessage(m) {
60
- if (this.invocation.nbEntriesToReplay === 1) {
61
- this.transitionState(NewExecutionState.PROCESSING);
62
- }
63
- const rootEntry = new JournalEntry(p.POLL_INPUT_STREAM_ENTRY_MESSAGE_TYPE, m);
64
- this.pendingJournalEntries.set(0, rootEntry);
65
- }
66
- handleUserSideMessage(messageType, message
67
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
- ) {
69
- this.incrementUserCodeIndex();
70
- switch (this.state) {
71
- case NewExecutionState.REPLAYING: {
72
- const replayEntry = this.invocation.replayEntries.get(this.userCodeJournalIndex);
73
- if (replayEntry === undefined) {
74
- throw errors_1.RetryableError.internal(`Illegal state: no replay message was received for the entry at journal index ${this.userCodeJournalIndex}`);
75
- }
76
- const journalEntry = new JournalEntry(messageType, message);
77
- this.handleReplay(this.userCodeJournalIndex, replayEntry, journalEntry);
78
- return journalEntry.promise;
79
- }
80
- case NewExecutionState.PROCESSING: {
81
- switch (messageType) {
82
- case p.SUSPENSION_MESSAGE_TYPE:
83
- case p.OUTPUT_STREAM_ENTRY_MESSAGE_TYPE: {
84
- this.handleClosingMessage(messageType, message);
85
- return Promise.resolve(undefined);
86
- }
87
- case p.SET_STATE_ENTRY_MESSAGE_TYPE:
88
- case p.CLEAR_STATE_ENTRY_MESSAGE_TYPE:
89
- case p.COMPLETE_AWAKEABLE_ENTRY_MESSAGE_TYPE:
90
- case p.BACKGROUND_INVOKE_ENTRY_MESSAGE_TYPE: {
91
- // Do not need completion
92
- return RESOLVED;
93
- }
94
- case p.GET_STATE_ENTRY_MESSAGE_TYPE: {
95
- const getStateMsg = message;
96
- if (getStateMsg.value !== undefined ||
97
- getStateMsg.empty !== undefined) {
98
- // State was eagerly filled by the local state store
99
- return Promise.resolve(getStateMsg.value || getStateMsg.empty);
100
- }
101
- else {
102
- // Need to retrieve state by going to the runtime.
103
- const journalEntry = new JournalEntry(messageType, message);
104
- this.pendingJournalEntries.set(this.userCodeJournalIndex, journalEntry);
105
- return journalEntry.promise;
106
- }
107
- }
108
- default: {
109
- // Need completion
110
- const journalEntry = new JournalEntry(messageType, message);
111
- this.pendingJournalEntries.set(this.userCodeJournalIndex, journalEntry);
112
- return journalEntry.promise;
113
- }
114
- }
115
- }
116
- case NewExecutionState.CLOSED: {
117
- // We cannot do anything anymore because an output was already sent back
118
- // This should actually never happen because the state is only transitioned to closed if the root promise is resolved/rejected
119
- // So no more user messages can come in...
120
- // - Print warning log and continue...
121
- //TODO received user-side message but state machine is closed
122
- return Promise.resolve(undefined);
123
- }
124
- default: {
125
- throw errors_1.RetryableError.protocolViolation("Did not receive input message before other messages.");
126
- }
127
- }
128
- }
129
- isUnResolved(index) {
130
- const journalEntry = this.pendingJournalEntries.get(index);
131
- return journalEntry !== undefined;
132
- }
133
- handleRuntimeCompletionMessage(m) {
134
- // Get message at that entryIndex in pendingJournalEntries
135
- const journalEntry = this.pendingJournalEntries.get(m.entryIndex);
136
- if (journalEntry === undefined) {
137
- //TODO received completion message but there is no pending promise for that index
138
- return;
139
- }
140
- if (m.value !== undefined) {
141
- journalEntry.resolve(m.value);
142
- this.pendingJournalEntries.delete(m.entryIndex);
143
- }
144
- else if (m.failure !== undefined) {
145
- // we do all completions with Terminal Errors, because failures triggered by those exceptions
146
- // when the bubble up would otherwise lead to re-tries, deterministic replay, re-throwing, and
147
- // thus an infinite loop that keeps replay-ing but never makes progress
148
- // these failures here consequently need to cause terminal failures, unless caught and handled
149
- // by the handler code
150
- journalEntry.reject((0, errors_1.failureToError)(m.failure, true));
151
- this.pendingJournalEntries.delete(m.entryIndex);
152
- }
153
- else if (m.empty !== undefined) {
154
- journalEntry.resolve(m.empty);
155
- this.pendingJournalEntries.delete(m.entryIndex);
156
- }
157
- else {
158
- //TODO completion message without a value/failure/empty
159
- }
160
- }
161
- handleEntryAckMessage(m) {
162
- // Get message at that entryIndex in pendingJournalEntries
163
- const journalEntry = this.pendingJournalEntries.get(m.entryIndex);
164
- if (journalEntry === undefined) {
165
- return;
166
- }
167
- // Just needs an ack
168
- journalEntry.resolve(undefined);
169
- this.pendingJournalEntries.delete(m.entryIndex);
170
- }
171
- handleReplay(journalIndex, replayMessage, journalEntry) {
172
- // Do the journal mismatch check
173
- const match = this.checkJournalMatch(replayMessage.messageType, replayMessage.message, journalEntry.messageType, journalEntry.message);
174
- // Journal mismatch check failedf
175
- if (!match) {
176
- throw errors_1.RetryableError.journalMismatch(journalIndex, replayMessage, journalEntry);
177
- }
178
- // If journal mismatch check passed
179
- /*
180
- - Else if the runtime replay message contains a completion
181
- - If the completion is a value
182
- - Return the resolved user code promise with the value
183
- - Else if the completion is a failure
184
- - Return the rejected user code promise with the failure as Error
185
- - Else if the completion is an Empty message
186
- - Return the resolved user code promise with the Empty message
187
- - Remove the journal entry
188
- - Else the replayed message was uncompleted
189
- - Create the user code promise
190
- - Add message to the pendingJournalEntries
191
- - Return the user code promise
192
- */
193
- switch (journalEntry.messageType) {
194
- case protocol_1.SUSPENSION_MESSAGE_TYPE:
195
- case protocol_1.OUTPUT_STREAM_ENTRY_MESSAGE_TYPE: {
196
- this.handleClosingMessage(journalEntry.messageType, journalEntry.message);
197
- break;
198
- }
199
- case protocol_1.GET_STATE_ENTRY_MESSAGE_TYPE: {
200
- const getStateMsg = replayMessage.message;
201
- this.resolveResult(journalIndex, journalEntry, getStateMsg.value || getStateMsg.empty, getStateMsg.failure);
202
- break;
203
- }
204
- case protocol_1.INVOKE_ENTRY_MESSAGE_TYPE: {
205
- const invokeMsg = replayMessage.message;
206
- this.resolveResult(journalIndex, journalEntry, invokeMsg.value, invokeMsg.failure);
207
- break;
208
- }
209
- case protocol_1.SLEEP_ENTRY_MESSAGE_TYPE: {
210
- const sleepMsg = replayMessage.message;
211
- this.resolveResult(journalIndex, journalEntry, sleepMsg.empty, sleepMsg.failure);
212
- break;
213
- }
214
- case protocol_1.AWAKEABLE_ENTRY_MESSAGE_TYPE: {
215
- const awakeableMsg = replayMessage.message;
216
- this.resolveResult(journalIndex, journalEntry, awakeableMsg.value, awakeableMsg.failure);
217
- break;
218
- }
219
- case protocol_1.SIDE_EFFECT_ENTRY_MESSAGE_TYPE: {
220
- const sideEffectMsg = replayMessage.message;
221
- if (sideEffectMsg.value !== undefined) {
222
- this.resolveResult(journalIndex, journalEntry, (0, utils_1.jsonDeserialize)(sideEffectMsg.value.toString()));
223
- }
224
- else if (sideEffectMsg.failure !== undefined) {
225
- this.resolveResult(journalIndex, journalEntry, undefined, sideEffectMsg.failure.failure, sideEffectMsg.failure.terminal);
226
- }
227
- else {
228
- // A side effect can have a void return type
229
- // If it was replayed, then it is acked, so we should resolve it.
230
- journalEntry.resolve(undefined);
231
- this.pendingJournalEntries.delete(journalIndex);
232
- }
233
- break;
234
- }
235
- case protocol_1.SET_STATE_ENTRY_MESSAGE_TYPE:
236
- case protocol_1.CLEAR_STATE_ENTRY_MESSAGE_TYPE:
237
- case protocol_1.COMPLETE_AWAKEABLE_ENTRY_MESSAGE_TYPE:
238
- case protocol_1.BACKGROUND_INVOKE_ENTRY_MESSAGE_TYPE: {
239
- // Do not need a completion. So if the match has passed then the entry can be deleted.
240
- journalEntry.resolve(undefined);
241
- this.pendingJournalEntries.delete(journalIndex);
242
- break;
243
- }
244
- default: {
245
- // TODO received replay message of unknown type
246
- }
247
- }
248
- }
249
- resolveResult(journalIndex, journalEntry, value, failure, failureWouldBeTerminal) {
250
- if (value !== undefined) {
251
- journalEntry.resolve(value);
252
- this.pendingJournalEntries.delete(journalIndex);
253
- }
254
- else if (failure !== undefined) {
255
- const error = (0, errors_1.failureToError)(failure, failureWouldBeTerminal ?? true);
256
- journalEntry.reject(error);
257
- this.pendingJournalEntries.delete(journalIndex);
258
- }
259
- else {
260
- this.pendingJournalEntries.set(journalIndex, journalEntry);
261
- }
262
- }
263
- handleClosingMessage(messageType, message) {
264
- this.transitionState(NewExecutionState.CLOSED);
265
- const rootJournalEntry = this.pendingJournalEntries.get(0);
266
- if (rootJournalEntry === undefined) {
267
- // We have no other option than to throw an error here
268
- // Because without the root promise we cannot resolve the method or continue
269
- throw errors_1.RetryableError.internal("Illegal state: No root journal entry found to resolve with output stream message");
270
- }
271
- this.pendingJournalEntries.delete(0);
272
- rootJournalEntry.resolve(new types_1.Message(messageType, message));
273
- }
274
- checkJournalMatch(runtimeMsgType, runtimeMsg, userCodeMsgType, userCodeMsg) {
275
- if (runtimeMsgType === userCodeMsgType) {
276
- const equalityFct = utils_1.equalityCheckers.get(runtimeMsgType);
277
- if (equalityFct === undefined) {
278
- // TODO no equality function was defined for the message type
279
- return true;
280
- }
281
- return equalityFct(runtimeMsg, userCodeMsg);
282
- }
283
- else {
284
- return false;
285
- }
286
- }
287
- // To get the indices that need to be completed with suspension
288
- getCompletableIndices() {
289
- // return all entries except for the root entry
290
- return [...this.pendingJournalEntries.entries()]
291
- .filter((el) => el[0] !== 0)
292
- .map((el) => el[0]);
293
- }
294
- transitionState(newExecState) {
295
- // If the state is already closed then you cannot transition anymore
296
- if (this.state === NewExecutionState.CLOSED &&
297
- newExecState !== NewExecutionState.CLOSED) {
298
- // do nothing
299
- return;
300
- }
301
- else {
302
- this.state = newExecState;
303
- return;
304
- }
305
- }
306
- incrementUserCodeIndex() {
307
- this.userCodeJournalIndex++;
308
- if (this.userCodeJournalIndex === this.invocation.nbEntriesToReplay &&
309
- this.state === NewExecutionState.REPLAYING) {
310
- this.transitionState(NewExecutionState.PROCESSING);
311
- }
312
- }
313
- isClosed() {
314
- return this.state === NewExecutionState.CLOSED;
315
- }
316
- isProcessing() {
317
- return this.state === NewExecutionState.PROCESSING;
318
- }
319
- getUserCodeJournalIndex() {
320
- return this.userCodeJournalIndex;
321
- }
322
- close() {
323
- this.transitionState(NewExecutionState.CLOSED);
324
- }
325
- outputMsgWasReplayed() {
326
- // Check if the last message of the replay entries is an output message
327
- const lastEntry = this.invocation.replayEntries.get(this.invocation.nbEntriesToReplay - 1);
328
- return (lastEntry && lastEntry.messageType === protocol_1.OUTPUT_STREAM_ENTRY_MESSAGE_TYPE);
329
- }
330
- // We use this for side effects.
331
- // The restate context needs to know if the user-defined fct needs to be executed or not.
332
- // It needs to know this before it can craft the message and call this.stateMachine.handleUserSideMessage(...)
333
- // so before the index got incremented and the state got transitioned.
334
- // So we cannot use isReplaying().
335
- // So we need to check in the journal if the next entry (= our side effect) will be replayed or not.
336
- nextEntryWillBeReplayed() {
337
- return this.userCodeJournalIndex + 1 < this.invocation.nbEntriesToReplay;
338
- }
339
- }
340
- exports.Journal = Journal;
341
- class JournalEntry {
342
- messageType;
343
- message;
344
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
345
- promise;
346
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
347
- resolve;
348
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
349
- reject;
350
- constructor(messageType, message) {
351
- this.messageType = messageType;
352
- this.message = message;
353
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
354
- this.promise = new Promise((res, rej) => {
355
- this.resolve = res;
356
- this.reject = rej;
357
- });
358
- }
359
- }
360
- exports.JournalEntry = JournalEntry;
361
- // "WAITING_FOR_START" before receiving start message
362
- // "WAITING_FOR_REPLAY" when waiting for all replay entries to arrive from the runtime
363
- // "REPLAYING" when receiving input stream message
364
- // "PROCESSING" when both sides have finished replaying
365
- // "CLOSED" when input stream connection channel gets closed
366
- var NewExecutionState;
367
- (function (NewExecutionState) {
368
- NewExecutionState["REPLAYING"] = "REPLAYING";
369
- NewExecutionState["PROCESSING"] = "PROCESSING";
370
- NewExecutionState["CLOSED"] = "CLOSED";
371
- })(NewExecutionState = exports.NewExecutionState || (exports.NewExecutionState = {}));
372
- //# sourceMappingURL=journal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"journal.js","sourceRoot":"","sources":["../src/journal.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AAEtC,+CAsB0B;AAC1B,yCAAkE;AAClE,yCAAwC;AAGxC,2CAAgE;AAEhE,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAE5C,MAAa,OAAO;IASG;IARb,KAAK,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAEpC,oBAAoB,GAAG,CAAC,CAAC;IAEjC,4DAA4D;IAC5D,4CAA4C;IACpC,qBAAqB,GAAG,IAAI,GAAG,EAAwB,CAAC;IAEhE,YAAqB,UAA4B;QAA5B,eAAU,GAAV,UAAU,CAAkB;QAC/C,MAAM,YAAY,GAAG,UAAU,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC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