@restatedev/restate-sdk 0.7.0 → 0.7.2-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 +26133 -0
  2. package/dist/io/encoder.d.ts +2 -1
  3. package/dist/io/encoder.d.ts.map +1 -1
  4. package/package.json +6 -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,72 +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
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.LocalStateStore = void 0;
14
- const protocol_1 = require("./generated/proto/protocol");
15
- const empty_1 = require("./generated/google/protobuf/empty");
16
- const utils_1 = require("./utils/utils");
17
- class LocalStateStore {
18
- isPartial;
19
- state;
20
- constructor(isPartial, state) {
21
- this.isPartial = isPartial;
22
- this.state = new Map(state.map(({ key, value }) => [key.toString(), value]));
23
- }
24
- get(key) {
25
- const present = this.state.has(key.toString());
26
- if (!present && this.isPartial) {
27
- // Partial eager state, so retrieve state from the runtime
28
- return protocol_1.GetStateEntryMessage.create({ key: Buffer.from(key) });
29
- }
30
- else if (!present) {
31
- // Complete eager state, so state entry is null
32
- return protocol_1.GetStateEntryMessage.create({
33
- key: Buffer.from(key),
34
- empty: empty_1.Empty.create({}),
35
- });
36
- }
37
- const stateEntry = this.state.get(key.toString());
38
- if (stateEntry instanceof Buffer) {
39
- return protocol_1.GetStateEntryMessage.create({
40
- key: Buffer.from(key),
41
- value: stateEntry,
42
- });
43
- }
44
- else {
45
- // stateEntry is Empty
46
- return protocol_1.GetStateEntryMessage.create({
47
- key: Buffer.from(key),
48
- empty: stateEntry,
49
- });
50
- }
51
- }
52
- set(key, value) {
53
- const bytes = Buffer.from((0, utils_1.jsonSerialize)(value));
54
- this.state.set(key, bytes);
55
- return protocol_1.SetStateEntryMessage.create({
56
- key: Buffer.from(key, "utf8"),
57
- value: bytes,
58
- });
59
- }
60
- clear(key) {
61
- this.state.set(key, empty_1.Empty.create({}));
62
- return protocol_1.ClearStateEntryMessage.create({ key: Buffer.from(key) });
63
- }
64
- // When a GetState request does not have a local entry and we have partial state,
65
- // then the request goes to the runtime.
66
- // When we get the response of the runtime, we add the state to the localStateStore.
67
- add(key, result) {
68
- this.state.set(key, result);
69
- }
70
- }
71
- exports.LocalStateStore = LocalStateStore;
72
- //# sourceMappingURL=local_state_store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"local_state_store.js","sourceRoot":"","sources":["../src/local_state_store.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,yDAKoC;AACpC,6DAA0D;AAC1D,yCAA8C;AAE9C,MAAa,eAAe;IAGL;IAFb,KAAK,CAA8B;IAE3C,YAAqB,SAAkB,EAAE,KAAgC;QAApD,cAAS,GAAT,SAAS,CAAS;QACrC,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,CAClB,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC,CACvD,CAAC;IACJ,CAAC;IAEM,GAAG,CAAC,GAAW;QACpB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE;YAC9B,0DAA0D;YAC1D,OAAO,+BAAoB,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;SAC/D;aAAM,IAAI,CAAC,OAAO,EAAE;YACnB,+CAA+C;YAC/C,OAAO,+BAAoB,CAAC,MAAM,CAA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AoF;IAC7E,GAAG,CAAC,GAAW,EAAE,MAAsB;QAC5C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC;CACF;AAzDD,0CAyDC"}
@@ -1,58 +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.connection = exports.RestateConnection = exports.Event = exports.TerminalError = exports.RestateError = exports.ErrorCodes = exports.RestateUtils = exports.createLambdaApiGatewayHandler = exports.LambdaRestateServer = exports.createServer = exports.keyedEventHandler = exports.keyedRouter = exports.router = exports.useContext = void 0;
37
- var restate_context_1 = require("./restate_context");
38
- Object.defineProperty(exports, "useContext", { enumerable: true, get: function () { return restate_context_1.useContext; } });
39
- var router_1 = require("./types/router");
40
- Object.defineProperty(exports, "router", { enumerable: true, get: function () { return router_1.router; } });
41
- Object.defineProperty(exports, "keyedRouter", { enumerable: true, get: function () { return router_1.keyedRouter; } });
42
- Object.defineProperty(exports, "keyedEventHandler", { enumerable: true, get: function () { return router_1.keyedEventHandler; } });
43
- var restate_server_1 = require("./server/restate_server");
44
- Object.defineProperty(exports, "createServer", { enumerable: true, get: function () { return restate_server_1.createServer; } });
45
- var restate_lambda_handler_1 = require("./server/restate_lambda_handler");
46
- Object.defineProperty(exports, "LambdaRestateServer", { enumerable: true, get: function () { return restate_lambda_handler_1.LambdaRestateServer; } });
47
- Object.defineProperty(exports, "createLambdaApiGatewayHandler", { enumerable: true, get: function () { return restate_lambda_handler_1.createLambdaApiGatewayHandler; } });
48
- exports.RestateUtils = __importStar(require("./utils/public_utils"));
49
- var errors_1 = require("./types/errors");
50
- Object.defineProperty(exports, "ErrorCodes", { enumerable: true, get: function () { return errors_1.ErrorCodes; } });
51
- Object.defineProperty(exports, "RestateError", { enumerable: true, get: function () { return errors_1.RestateError; } });
52
- Object.defineProperty(exports, "TerminalError", { enumerable: true, get: function () { return errors_1.TerminalError; } });
53
- var types_1 = require("./types/types");
54
- Object.defineProperty(exports, "Event", { enumerable: true, get: function () { return types_1.Event; } });
55
- var api_1 = require("./embedded/api");
56
- Object.defineProperty(exports, "RestateConnection", { enumerable: true, get: function () { return api_1.RestateConnection; } });
57
- Object.defineProperty(exports, "connection", { enumerable: true, get: function () { return api_1.connection; } });
58
- //# sourceMappingURL=public_api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"public_api.js","sourceRoot":"","sources":["../src/public_api.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,qDAM2B;AAHzB,6GAAA,UAAU,OAAA;AAIZ,yCASwB;AARtB,gGAAA,MAAM,OAAA;AACN,qGAAA,WAAW,OAAA;AACX,2GAAA,iBAAiB,OAAA;AAOnB,0DAAsE;AAA9C,8GAAA,YAAY,OAAA;AAEpC,0EAGyC;AAFvC,6HAAA,mBAAmB,OAAA;AACnB,uIAAA,6BAA6B,OAAA;AAE/B,qEAAqD;AACrD,yCAAyE;AAAhE,oGAAA,UAAU,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,uGAAA,aAAa,OAAA;AAChD,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AACd,sCAIwB;AAHtB,wGAAA,iBAAiB,OAAA;AACjB,iGAAA,UAAU,OAAA"}
@@ -1,46 +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
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.setContext = exports.useContext = void 0;
14
- // Use our prefixed logger instead of default console logging
15
- require("./utils/logger");
16
- /**
17
- * Returns the RestateContext which is the entrypoint for all interaction with Restate.
18
- * Use this from within a method to retrieve the RestateContext.
19
- * The context is bounded to a single invocation.
20
- *
21
- * @example
22
- * const ctx = restate.useContext(this);
23
- *
24
- */
25
- function useContext(instance) {
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
- const wrapper = instance;
28
- if (wrapper.$$restate === undefined || wrapper.$$restate === null) {
29
- throw new Error(`not running within a Restate call.`);
30
- }
31
- return wrapper.$$restate;
32
- }
33
- exports.useContext = useContext;
34
- function setContext(instance, context) {
35
- // creates a *new*, per call object that shares all the properties that @instance has
36
- // except '$$restate' which is a unique, per call pointer to a restate context.
37
- //
38
- // The following line create a new object, that its prototype is @instance.
39
- // and that object has a $$restate property.
40
- const wrapper = Object.create(instance, {
41
- $$restate: { value: context },
42
- });
43
- return wrapper;
44
- }
45
- exports.setContext = setContext;
46
- //# sourceMappingURL=restate_context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"restate_context.js","sourceRoot":"","sources":["../src/restate_context.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,6DAA6D;AAC7D,0BAAwB;AAgSxB;;;;;;;;GAQG;AACH,SAAgB,UAAU,CAAI,QAAW;IACvC,8DAA8D;IAC9D,MAAM,OAAO,GAAG,QAAe,CAAC;IAChC,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,EAAE;QACjE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;KACvD;IACD,OAAO,OAAO,CAAC,SAAS,CAAC;AAC3B,CAAC;AAPD,gCAOC;AAED,SAAgB,UAAU,CAAI,QAAW,EAAE,OAA2B;IACpE,qFAAqF;IACrF,+EAA+E;IAC/E,EAAE;IACF,2EAA2E;IAC3E,4CAA4C;IAC5C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE;QAChD,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;KAC9B,CAAC,CAAC;IACH,OAAO,OAAY,CAAC;AACtB,CAAC;AAVD,gCAUC"}
@@ -1,375 +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
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.RpcContextImpl = exports.RestateGrpcContextImpl = exports.CallContexType = void 0;
14
- const protocol_1 = require("./generated/proto/protocol");
15
- const protocol_2 = require("./types/protocol");
16
- const javascript_1 = require("./generated/proto/javascript");
17
- const async_hooks_1 = require("async_hooks");
18
- const errors_1 = require("./types/errors");
19
- const utils_1 = require("./utils/utils");
20
- const public_utils_1 = require("./utils/public_utils");
21
- const logger_1 = require("./utils/logger");
22
- const dynrpc_1 = require("./generated/proto/dynrpc");
23
- const assumpsions_1 = require("./utils/assumpsions");
24
- const rand_1 = require("./utils/rand");
25
- var CallContexType;
26
- (function (CallContexType) {
27
- CallContexType[CallContexType["None"] = 0] = "None";
28
- CallContexType[CallContexType["SideEffect"] = 1] = "SideEffect";
29
- CallContexType[CallContexType["OneWayCall"] = 2] = "OneWayCall";
30
- })(CallContexType = exports.CallContexType || (exports.CallContexType = {}));
31
- class RestateGrpcContextImpl {
32
- id;
33
- serviceName;
34
- stateMachine;
35
- rand;
36
- // here, we capture the context information for actions on the Restate context that
37
- // are executed within other actions, such as
38
- // ctx.oneWayCall( () => client.foo(bar) );
39
- // we also use this information to ensure we check that only allowed operations are
40
- // used. Within side-effects, no operations are allowed on the RestateContext.
41
- // For example, this is illegal: 'ctx.sideEffect(() => {await ctx.get("my-state")})'
42
- static callContext = new async_hooks_1.AsyncLocalStorage();
43
- constructor(id, serviceName,
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
- stateMachine, rand = new rand_1.RandImpl(id)) {
46
- this.id = id;
47
- this.serviceName = serviceName;
48
- this.stateMachine = stateMachine;
49
- this.rand = rand;
50
- }
51
- async get(name) {
52
- // Check if this is a valid action
53
- this.checkState("get state");
54
- // Create the message and let the state machine process it
55
- const msg = this.stateMachine.localStateStore.get(name);
56
- const result = await this.stateMachine.handleUserCodeMessage(protocol_2.GET_STATE_ENTRY_MESSAGE_TYPE, msg);
57
- // If the GetState message did not have a value or empty,
58
- // then we went to the runtime to get the value.
59
- // When we get the response, we set it in the localStateStore,
60
- // to answer subsequent requests
61
- if (msg.value === undefined && msg.empty === undefined) {
62
- this.stateMachine.localStateStore.add(name, result);
63
- }
64
- if (!(result instanceof Buffer)) {
65
- return null;
66
- }
67
- return (0, utils_1.jsonDeserialize)(result.toString());
68
- }
69
- set(name, value) {
70
- this.checkState("set state");
71
- const msg = this.stateMachine.localStateStore.set(name, value);
72
- this.stateMachine.handleUserCodeMessage(protocol_2.SET_STATE_ENTRY_MESSAGE_TYPE, msg);
73
- }
74
- clear(name) {
75
- this.checkState("clear state");
76
- const msg = this.stateMachine.localStateStore.clear(name);
77
- this.stateMachine.handleUserCodeMessage(protocol_2.CLEAR_STATE_ENTRY_MESSAGE_TYPE, msg);
78
- }
79
- request(service, method, data) {
80
- if (this.isInOneWayCall()) {
81
- return this.invokeOneWay(service, method, data);
82
- }
83
- else {
84
- return this.invoke(service, method, data);
85
- }
86
- }
87
- async invoke(service, method, data) {
88
- this.checkState("invoke");
89
- const msg = protocol_1.InvokeEntryMessage.create({
90
- serviceName: service,
91
- methodName: method,
92
- parameter: Buffer.from(data),
93
- });
94
- const promise = this.stateMachine.handleUserCodeMessage(protocol_2.INVOKE_ENTRY_MESSAGE_TYPE, msg);
95
- return (await promise);
96
- }
97
- async invokeOneWay(service, method, data) {
98
- const delay = this.getOneWayCallDelay();
99
- const invokeTime = delay > 0 ? Date.now() + delay : undefined;
100
- const msg = protocol_1.BackgroundInvokeEntryMessage.create({
101
- serviceName: service,
102
- methodName: method,
103
- parameter: Buffer.from(data),
104
- invokeTime: invokeTime,
105
- });
106
- await this.stateMachine.handleUserCodeMessage(protocol_2.BACKGROUND_INVOKE_ENTRY_MESSAGE_TYPE, msg);
107
- return new Uint8Array();
108
- }
109
- async oneWayCall(
110
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
- call) {
112
- this.checkState("oneWayCall");
113
- await RestateGrpcContextImpl.callContext.run({ type: CallContexType.OneWayCall }, call);
114
- }
115
- async delayedCall(
116
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
117
- call, delayMillis) {
118
- this.checkState("delayedCall");
119
- // Delayed call is a one way call with a delay
120
- await RestateGrpcContextImpl.callContext.run({ type: CallContexType.OneWayCall, delay: delayMillis }, call);
121
- }
122
- async sideEffect(fn, retryPolicy = public_utils_1.DEFAULT_INFINITE_EXPONENTIAL_BACKOFF) {
123
- if (this.isInSideEffect()) {
124
- throw new errors_1.TerminalError("You cannot do sideEffect calls from within a side effect.", { errorCode: errors_1.ErrorCodes.INTERNAL });
125
- }
126
- else if (this.isInOneWayCall()) {
127
- throw new errors_1.TerminalError("Cannot do a side effect from within ctx.oneWayCall(...). " +
128
- "Context method ctx.oneWayCall() can only be used to invoke other services unidirectionally. " +
129
- "e.g. ctx.oneWayCall(() => client.greet(my_request))", { errorCode: errors_1.ErrorCodes.INTERNAL });
130
- }
131
- const executeAndLogSideEffect = async () => {
132
- // in replay mode, we directly return the value from the log
133
- if (this.stateMachine.nextEntryWillBeReplayed()) {
134
- const emptyMsg = javascript_1.SideEffectEntryMessage.create({});
135
- return this.stateMachine.handleUserCodeMessage(protocol_2.SIDE_EFFECT_ENTRY_MESSAGE_TYPE, emptyMsg);
136
- }
137
- let sideEffectResult;
138
- try {
139
- sideEffectResult = await RestateGrpcContextImpl.callContext.run({ type: CallContexType.SideEffect }, fn);
140
- }
141
- catch (e) {
142
- // we commit any error from the side effet to thr journal, and re-throw it into
143
- // the function. that way, any catching by the user and reacting to it will be
144
- // deterministic on replay
145
- const error = (0, errors_1.ensureError)(e);
146
- const failure = (0, errors_1.errorToFailureWithTerminal)(error);
147
- const sideEffectMsg = javascript_1.SideEffectEntryMessage.create({
148
- failure: failure,
149
- });
150
- // this may throw an error from the SDK/runtime/connection side, in case the
151
- // failure message cannot be committed to the journal. That error would then
152
- // be returned from this function (replace the original error)
153
- // that is acceptable, because in such a situation (failure to append to journal),
154
- // the state machine closes anyways and no further operations will succeed and the
155
- // the execution aborts
156
- await this.stateMachine.handleUserCodeMessage(protocol_2.SIDE_EFFECT_ENTRY_MESSAGE_TYPE, sideEffectMsg, false, undefined, true);
157
- throw e;
158
- }
159
- // we have this code outside the above try/catch block, to ensure that any error arising
160
- // from here is not incorrectly attributed to the side-effect
161
- const sideEffectMsg = sideEffectResult !== undefined
162
- ? javascript_1.SideEffectEntryMessage.create({
163
- value: Buffer.from((0, utils_1.jsonSerialize)(sideEffectResult)),
164
- })
165
- : javascript_1.SideEffectEntryMessage.create();
166
- // if an error arises from committing the side effect result, then this error will
167
- // be thrown here (reject the returned promise) and the function will see that error,
168
- // even if the side-effect function completed correctly
169
- // that is acceptable, because in such a situation (failure to append to journal),
170
- // the state machine closes anyways and reports an execution failure, meaning no further
171
- // operations will succeed and the the execution will be retried.
172
- // If the side-effect result did in fact not make it to the journal, then the side-effect
173
- // re-executes, and if it made it to the journal after all (error happend inly during
174
- // ack-back), then retries will use the journaled result.
175
- // So all good in any case, due to the beauty of "the runtime log is the ground thruth" approach.
176
- await this.stateMachine.handleUserCodeMessage(protocol_2.SIDE_EFFECT_ENTRY_MESSAGE_TYPE, sideEffectMsg, false, undefined, true);
177
- return sideEffectResult;
178
- };
179
- const sleep = (millis) => this.sleep(millis);
180
- return executeWithRetries(retryPolicy, executeAndLogSideEffect, sleep);
181
- }
182
- sleep(millis) {
183
- this.checkState("sleep");
184
- const msg = protocol_1.SleepEntryMessage.create({ wakeUpTime: Date.now() + millis });
185
- return this.stateMachine.handleUserCodeMessage(protocol_2.SLEEP_ENTRY_MESSAGE_TYPE, msg);
186
- }
187
- awakeable() {
188
- this.checkState("awakeable");
189
- const msg = protocol_1.AwakeableEntryMessage.create();
190
- const promise = this.stateMachine
191
- .handleUserCodeMessage(protocol_2.AWAKEABLE_ENTRY_MESSAGE_TYPE, msg)
192
- .transform((result) => {
193
- if (!(result instanceof Buffer)) {
194
- // This should either be a filled buffer or an empty buffer but never anything else.
195
- throw errors_1.RetryableError.internal("Awakeable was not resolved with a buffer payload");
196
- }
197
- return JSON.parse(result.toString());
198
- });
199
- // This needs to be done after handling the message in the state machine
200
- // otherwise the index is not yet incremented.
201
- const encodedEntryIndex = Buffer.alloc(4 /* Size of u32 */);
202
- encodedEntryIndex.writeUInt32BE(this.stateMachine.getUserCodeJournalIndex());
203
- return {
204
- id: Buffer.concat([this.id, encodedEntryIndex]).toString("base64url"),
205
- promise: promise,
206
- };
207
- }
208
- resolveAwakeable(id, payload) {
209
- this.checkState("resolveAwakeable");
210
- this.completeAwakeable(id, {
211
- value: Buffer.from(JSON.stringify(payload)),
212
- });
213
- }
214
- rejectAwakeable(id, reason) {
215
- this.checkState("rejectAwakeable");
216
- this.completeAwakeable(id, {
217
- failure: { code: errors_1.ErrorCodes.UNKNOWN, message: reason },
218
- });
219
- }
220
- completeAwakeable(id, base) {
221
- base.id = id;
222
- this.stateMachine.handleUserCodeMessage(protocol_2.COMPLETE_AWAKEABLE_ENTRY_MESSAGE_TYPE, protocol_1.CompleteAwakeableEntryMessage.create(base));
223
- }
224
- isInSideEffect() {
225
- const context = RestateGrpcContextImpl.callContext.getStore();
226
- return context?.type === CallContexType.SideEffect;
227
- }
228
- isInOneWayCall() {
229
- const context = RestateGrpcContextImpl.callContext.getStore();
230
- return context?.type === CallContexType.OneWayCall;
231
- }
232
- getOneWayCallDelay() {
233
- const context = RestateGrpcContextImpl.callContext.getStore();
234
- return context?.delay || 0;
235
- }
236
- checkState(callType) {
237
- const context = RestateGrpcContextImpl.callContext.getStore();
238
- if (!context) {
239
- return;
240
- }
241
- if (context.type === CallContexType.SideEffect) {
242
- throw new errors_1.TerminalError(`You cannot do ${callType} calls from within a side effect.`, { errorCode: errors_1.ErrorCodes.INTERNAL });
243
- }
244
- if (context.type === CallContexType.OneWayCall) {
245
- throw new errors_1.TerminalError(`Cannot do a ${callType} from within ctx.oneWayCall(...).
246
- Context method oneWayCall() can only be used to invoke other services in the background.
247
- e.g. ctx.oneWayCall(() => client.greet(my_request))`, { errorCode: errors_1.ErrorCodes.INTERNAL });
248
- }
249
- }
250
- rpcGateway() {
251
- return new RpcContextImpl(this);
252
- }
253
- }
254
- exports.RestateGrpcContextImpl = RestateGrpcContextImpl;
255
- async function executeWithRetries(retrySettings, executeAndLogSideEffect, sleep) {
256
- const { initialDelayMs = public_utils_1.DEFAULT_INITIAL_DELAY_MS, maxDelayMs = Number.MAX_SAFE_INTEGER, maxRetries = Number.MAX_SAFE_INTEGER, policy = public_utils_1.EXPONENTIAL_BACKOFF, name = "side-effect", } = retrySettings;
257
- let currentDelayMs = initialDelayMs;
258
- let retriesLeft = maxRetries;
259
- // eslint-disable-next-line no-constant-condition
260
- while (true) {
261
- try {
262
- return await executeAndLogSideEffect();
263
- }
264
- catch (e) {
265
- if (e instanceof errors_1.TerminalError) {
266
- throw e;
267
- }
268
- // journal mismatch errors are special:
269
- // - they are not terminal errors, because we want to allow pushing new code so
270
- // that retries succeed later
271
- // - they are not retried within the service, because they will never succeed within this service,
272
- // but can only succeed within a new invocation going to service with fixed code
273
- // we hence break the retries here similar to terminal errors
274
- if (e instanceof errors_1.RestateError &&
275
- e.code == errors_1.RestateErrorCodes.JOURNAL_MISMATCH) {
276
- throw e;
277
- }
278
- const error = (0, errors_1.ensureError)(e);
279
- logger_1.rlog.debug("Error while executing side effect '%s': %s - %s", name, error.name, error.message);
280
- if (error.stack) {
281
- logger_1.rlog.debug(error.stack);
282
- }
283
- if (retriesLeft > 0) {
284
- logger_1.rlog.debug("Retrying in %d ms", currentDelayMs);
285
- }
286
- else {
287
- logger_1.rlog.debug("No retries left.");
288
- throw new errors_1.TerminalError(`Retries exhausted for ${name}. Last error: ${error.name}: ${error.message}`, {
289
- errorCode: errors_1.ErrorCodes.INTERNAL,
290
- });
291
- }
292
- }
293
- await sleep(currentDelayMs);
294
- retriesLeft -= 1;
295
- currentDelayMs = Math.min(policy.computeNextDelay(currentDelayMs), maxDelayMs);
296
- }
297
- }
298
- class RpcContextImpl {
299
- ctx;
300
- id;
301
- rand;
302
- serviceName;
303
- constructor(ctx, id = ctx.id, rand = ctx.rand, serviceName = ctx.serviceName) {
304
- this.ctx = ctx;
305
- this.id = id;
306
- this.rand = rand;
307
- this.serviceName = serviceName;
308
- }
309
- rpc({ path }) {
310
- const clientProxy = new Proxy({}, {
311
- get: (_target, prop) => {
312
- const route = prop;
313
- return async (...args) => {
314
- const request = (0, assumpsions_1.requestFromArgs)(args);
315
- const requestBytes = dynrpc_1.RpcRequest.encode(request).finish();
316
- const responseBytes = await this.ctx.request(path, route, requestBytes);
317
- const response = dynrpc_1.RpcResponse.decode(responseBytes);
318
- return response.response;
319
- };
320
- },
321
- });
322
- return clientProxy;
323
- }
324
- send(options) {
325
- return this.sendDelayed(options, 0);
326
- }
327
- sendDelayed({ path }, delayMillis) {
328
- const clientProxy = new Proxy({}, {
329
- get: (_target, prop) => {
330
- const route = prop;
331
- return (...args) => {
332
- const request = (0, assumpsions_1.requestFromArgs)(args);
333
- const requestBytes = dynrpc_1.RpcRequest.encode(request).finish();
334
- const sender = () => this.ctx.request(path, route, requestBytes);
335
- if (delayMillis === undefined || delayMillis === 0) {
336
- this.ctx.oneWayCall(sender);
337
- }
338
- else {
339
- this.ctx.delayedCall(sender, delayMillis);
340
- }
341
- };
342
- },
343
- });
344
- return clientProxy;
345
- }
346
- get(name) {
347
- return this.ctx.get(name);
348
- }
349
- set(name, value) {
350
- this.ctx.set(name, value);
351
- }
352
- clear(name) {
353
- this.ctx.clear(name);
354
- }
355
- sideEffect(fn) {
356
- return this.ctx.sideEffect(fn);
357
- }
358
- awakeable() {
359
- return this.ctx.awakeable();
360
- }
361
- resolveAwakeable(id, payload) {
362
- this.ctx.resolveAwakeable(id, payload);
363
- }
364
- rejectAwakeable(id, reason) {
365
- this.ctx.rejectAwakeable(id, reason);
366
- }
367
- sleep(millis) {
368
- return this.ctx.sleep(millis);
369
- }
370
- grpcChannel() {
371
- return this.ctx;
372
- }
373
- }
374
- exports.RpcContextImpl = RpcContextImpl;
375
- //# sourceMappingURL=restate_context_impl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"restate_context_impl.js","sourceRoot":"","sources":["../src/restate_context_impl.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAWH,yDAOoC;AACpC,+CAU0B;AAC1B,6DAAsE;AACtE,6CAAgD;AAChD,2CA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