@restatedev/restate-sdk 0.8.1 → 0.9.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/dist/{clients → src/clients}/workflow_client.d.ts +2 -2
- package/dist/src/clients/workflow_client.d.ts.map +1 -0
- package/dist/{clients → src/clients}/workflow_client.js +2 -2
- package/dist/src/clients/workflow_client.js.map +1 -0
- package/dist/{connection → src/connection}/buffered_connection.d.ts +1 -0
- package/dist/src/connection/buffered_connection.d.ts.map +1 -0
- package/dist/src/connection/buffered_connection.js.map +1 -0
- package/dist/src/connection/connection.d.ts.map +1 -0
- package/dist/src/connection/connection.js.map +1 -0
- package/dist/{connection → src/connection}/http_connection.d.ts +1 -1
- package/dist/src/connection/http_connection.d.ts.map +1 -0
- package/dist/{connection → src/connection}/http_connection.js +1 -1
- package/dist/src/connection/http_connection.js.map +1 -0
- package/dist/{connection → src/connection}/lambda_connection.d.ts +1 -0
- package/dist/src/connection/lambda_connection.d.ts.map +1 -0
- package/dist/{connection → src/connection}/lambda_connection.js +5 -4
- package/dist/src/connection/lambda_connection.js.map +1 -0
- package/dist/{context.d.ts → src/context.d.ts} +146 -224
- package/dist/src/context.d.ts.map +1 -0
- package/dist/{context.js → src/context.js} +6 -41
- package/dist/src/context.js.map +1 -0
- package/dist/src/context_impl.d.ts +62 -0
- package/dist/src/context_impl.d.ts.map +1 -0
- package/dist/{context_impl.js → src/context_impl.js} +201 -182
- package/dist/src/context_impl.js.map +1 -0
- package/dist/src/endpoint/endpoint_impl.d.ts +28 -0
- package/dist/src/endpoint/endpoint_impl.d.ts.map +1 -0
- package/dist/src/endpoint/endpoint_impl.js +164 -0
- package/dist/src/endpoint/endpoint_impl.js.map +1 -0
- package/dist/{endpoint → src/endpoint}/http2_handler.d.ts +1 -1
- package/dist/src/endpoint/http2_handler.d.ts.map +1 -0
- package/dist/src/endpoint/http2_handler.js +153 -0
- package/dist/src/endpoint/http2_handler.js.map +1 -0
- package/dist/{endpoint → src/endpoint}/lambda_handler.d.ts +2 -2
- package/dist/src/endpoint/lambda_handler.d.ts.map +1 -0
- package/dist/{endpoint → src/endpoint}/lambda_handler.js +66 -56
- package/dist/src/endpoint/lambda_handler.js.map +1 -0
- package/dist/src/endpoint/request_signing/basex.d.ts +10 -0
- package/dist/src/endpoint/request_signing/basex.d.ts.map +1 -0
- package/dist/src/endpoint/request_signing/basex.js +138 -0
- package/dist/src/endpoint/request_signing/basex.js.map +1 -0
- package/dist/src/endpoint/request_signing/ed25519.d.ts +17 -0
- package/dist/src/endpoint/request_signing/ed25519.d.ts.map +1 -0
- package/dist/src/endpoint/request_signing/ed25519.js +78 -0
- package/dist/src/endpoint/request_signing/ed25519.js.map +1 -0
- package/dist/src/endpoint/request_signing/v1.d.ts +9 -0
- package/dist/src/endpoint/request_signing/v1.d.ts.map +1 -0
- package/dist/src/endpoint/request_signing/v1.js +148 -0
- package/dist/src/endpoint/request_signing/v1.js.map +1 -0
- package/dist/src/endpoint/request_signing/validate.d.ts +18 -0
- package/dist/src/endpoint/request_signing/validate.d.ts.map +1 -0
- package/dist/src/endpoint/request_signing/validate.js +45 -0
- package/dist/src/endpoint/request_signing/validate.js.map +1 -0
- package/dist/src/endpoint.d.ts +102 -0
- package/dist/src/endpoint.d.ts.map +1 -0
- package/dist/{endpoint.js → src/endpoint.js} +1 -1
- package/dist/src/endpoint.js.map +1 -0
- package/dist/src/generated/proto/javascript_pb.d.ts +26 -0
- package/dist/src/generated/proto/javascript_pb.d.ts.map +1 -0
- package/dist/src/generated/proto/javascript_pb.js +52 -0
- package/dist/src/generated/proto/javascript_pb.js.map +1 -0
- package/dist/src/generated/proto/protocol_pb.d.ts +865 -0
- package/dist/src/generated/proto/protocol_pb.d.ts.map +1 -0
- package/dist/src/generated/proto/protocol_pb.js +1112 -0
- package/dist/src/generated/proto/protocol_pb.js.map +1 -0
- package/dist/src/generated/version.d.ts +2 -0
- package/dist/src/generated/version.d.ts.map +1 -0
- package/dist/src/generated/version.js +5 -0
- package/dist/src/generated/version.js.map +1 -0
- package/dist/{invocation.d.ts → src/invocation.d.ts} +14 -18
- package/dist/src/invocation.d.ts.map +1 -0
- package/dist/{invocation.js → src/invocation.js} +25 -24
- package/dist/src/invocation.js.map +1 -0
- package/dist/{io → src/io}/decoder.d.ts +3 -2
- package/dist/src/io/decoder.d.ts.map +1 -0
- package/dist/{io → src/io}/decoder.js +12 -10
- package/dist/src/io/decoder.js.map +1 -0
- package/dist/{io → src/io}/encoder.d.ts +1 -1
- package/dist/src/io/encoder.d.ts.map +1 -0
- package/dist/{io → src/io}/encoder.js +11 -21
- package/dist/src/io/encoder.js.map +1 -0
- package/dist/{journal.d.ts → src/journal.d.ts} +7 -7
- package/dist/src/journal.d.ts.map +1 -0
- package/dist/{journal.js → src/journal.js} +64 -46
- package/dist/src/journal.js.map +1 -0
- package/dist/{local_state_store.d.ts → src/local_state_store.d.ts} +2 -2
- package/dist/src/local_state_store.d.ts.map +1 -0
- package/dist/{local_state_store.js → src/local_state_store.js} +19 -17
- package/dist/src/local_state_store.js.map +1 -0
- package/dist/{logger.d.ts → src/logger.d.ts} +9 -1
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/logger.js +158 -0
- package/dist/src/logger.js.map +1 -0
- package/dist/src/promise_combinator_tracker.d.ts.map +1 -0
- package/dist/src/promise_combinator_tracker.js.map +1 -0
- package/dist/src/public_api.d.ts +7 -0
- package/dist/src/public_api.d.ts.map +1 -0
- package/dist/{public_api.js → src/public_api.js} +4 -14
- package/dist/src/public_api.js.map +1 -0
- package/dist/{state_machine.d.ts → src/state_machine.d.ts} +7 -4
- package/dist/src/state_machine.d.ts.map +1 -0
- package/dist/{state_machine.js → src/state_machine.js} +32 -34
- package/dist/src/state_machine.js.map +1 -0
- package/dist/src/types/components.d.ts +65 -0
- package/dist/src/types/components.d.ts.map +1 -0
- package/dist/src/types/components.js +163 -0
- package/dist/src/types/components.js.map +1 -0
- package/dist/src/types/discovery.d.ts +40 -0
- package/dist/src/types/discovery.d.ts.map +1 -0
- package/dist/src/types/discovery.js +29 -0
- package/dist/src/types/discovery.js.map +1 -0
- package/dist/src/types/errors.d.ts +53 -0
- package/dist/src/types/errors.d.ts.map +1 -0
- package/dist/src/types/errors.js +129 -0
- package/dist/src/types/errors.js.map +1 -0
- package/dist/src/types/protocol.d.ts +33 -0
- package/dist/src/types/protocol.d.ts.map +1 -0
- package/dist/{types → src/types}/protocol.js +52 -52
- package/dist/src/types/protocol.js.map +1 -0
- package/dist/src/types/rpc.d.ts +50 -0
- package/dist/src/types/rpc.d.ts.map +1 -0
- package/dist/src/types/rpc.js +38 -0
- package/dist/src/types/rpc.js.map +1 -0
- package/dist/{types → src/types}/types.d.ts +0 -9
- package/dist/src/types/types.d.ts.map +1 -0
- package/dist/{types → src/types}/types.js +4 -21
- package/dist/src/types/types.js.map +1 -0
- package/dist/src/user_agent.d.ts +2 -0
- package/dist/src/user_agent.d.ts.map +1 -0
- package/dist/src/user_agent.js +16 -0
- package/dist/src/user_agent.js.map +1 -0
- package/dist/src/utils/message_logger.d.ts +7 -0
- package/dist/src/utils/message_logger.d.ts.map +1 -0
- package/dist/{utils → src/utils}/message_logger.js +17 -26
- package/dist/src/utils/message_logger.js.map +1 -0
- package/dist/src/utils/promises.d.ts.map +1 -0
- package/dist/src/utils/promises.js.map +1 -0
- package/dist/{utils → src/utils}/rand.d.ts +1 -0
- package/dist/src/utils/rand.d.ts.map +1 -0
- package/dist/{utils → src/utils}/rand.js +7 -6
- package/dist/src/utils/rand.js.map +1 -0
- package/dist/src/utils/serde.d.ts +3 -0
- package/dist/src/utils/serde.d.ts.map +1 -0
- package/dist/src/utils/serde.js +24 -0
- package/dist/src/utils/serde.js.map +1 -0
- package/dist/{utils → src/utils}/utils.d.ts +0 -1
- package/dist/src/utils/utils.d.ts.map +1 -0
- package/dist/{utils → src/utils}/utils.js +36 -43
- package/dist/src/utils/utils.js.map +1 -0
- package/dist/{workflows → src/workflows}/workflow.d.ts +6 -6
- package/dist/src/workflows/workflow.d.ts.map +1 -0
- package/dist/{workflows → src/workflows}/workflow.js +11 -7
- package/dist/src/workflows/workflow.js.map +1 -0
- package/dist/src/workflows/workflow_state_service.d.ts +35 -0
- package/dist/src/workflows/workflow_state_service.d.ts.map +1 -0
- package/dist/{workflows → src/workflows}/workflow_state_service.js +11 -11
- package/dist/src/workflows/workflow_state_service.js.map +1 -0
- package/dist/{workflows → src/workflows}/workflow_wrapper_service.d.ts +2 -2
- package/dist/src/workflows/workflow_wrapper_service.d.ts.map +1 -0
- package/dist/{workflows → src/workflows}/workflow_wrapper_service.js +66 -45
- package/dist/src/workflows/workflow_wrapper_service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +13 -16
- package/LICENSE +0 -21
- package/README.md +0 -154
- package/dist/clients/workflow_client.d.ts.map +0 -1
- package/dist/clients/workflow_client.js.map +0 -1
- package/dist/connection/buffered_connection.d.ts.map +0 -1
- package/dist/connection/buffered_connection.js.map +0 -1
- package/dist/connection/connection.d.ts.map +0 -1
- package/dist/connection/connection.js.map +0 -1
- package/dist/connection/embedded_connection.d.ts +0 -20
- package/dist/connection/embedded_connection.d.ts.map +0 -1
- package/dist/connection/embedded_connection.js +0 -59
- package/dist/connection/embedded_connection.js.map +0 -1
- package/dist/connection/http_connection.d.ts.map +0 -1
- package/dist/connection/http_connection.js.map +0 -1
- package/dist/connection/lambda_connection.d.ts.map +0 -1
- package/dist/connection/lambda_connection.js.map +0 -1
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/context_impl.d.ts +0 -65
- package/dist/context_impl.d.ts.map +0 -1
- package/dist/context_impl.js.map +0 -1
- package/dist/embedded/api.d.ts +0 -27
- package/dist/embedded/api.d.ts.map +0 -1
- package/dist/embedded/api.js +0 -35
- package/dist/embedded/api.js.map +0 -1
- package/dist/embedded/handler.d.ts +0 -4
- package/dist/embedded/handler.d.ts.map +0 -1
- package/dist/embedded/handler.js +0 -26
- package/dist/embedded/handler.js.map +0 -1
- package/dist/embedded/http2_remote.d.ts +0 -11
- package/dist/embedded/http2_remote.d.ts.map +0 -1
- package/dist/embedded/http2_remote.js +0 -91
- package/dist/embedded/http2_remote.js.map +0 -1
- package/dist/embedded/invocation.d.ts +0 -5
- package/dist/embedded/invocation.d.ts.map +0 -1
- package/dist/embedded/invocation.js +0 -94
- package/dist/embedded/invocation.js.map +0 -1
- package/dist/endpoint/endpoint_impl.d.ts +0 -35
- package/dist/endpoint/endpoint_impl.d.ts.map +0 -1
- package/dist/endpoint/endpoint_impl.js +0 -405
- package/dist/endpoint/endpoint_impl.js.map +0 -1
- package/dist/endpoint/http2_handler.d.ts.map +0 -1
- package/dist/endpoint/http2_handler.js +0 -119
- package/dist/endpoint/http2_handler.js.map +0 -1
- package/dist/endpoint/lambda_handler.d.ts.map +0 -1
- package/dist/endpoint/lambda_handler.js.map +0 -1
- package/dist/endpoint.d.ts +0 -161
- package/dist/endpoint.d.ts.map +0 -1
- package/dist/endpoint.js.map +0 -1
- package/dist/generated/dev/restate/events.d.ts +0 -96
- package/dist/generated/dev/restate/events.d.ts.map +0 -1
- package/dist/generated/dev/restate/events.js +0 -371
- package/dist/generated/dev/restate/events.js.map +0 -1
- package/dist/generated/dev/restate/ext.d.ts +0 -91
- package/dist/generated/dev/restate/ext.d.ts.map +0 -1
- package/dist/generated/dev/restate/ext.js +0 -215
- package/dist/generated/dev/restate/ext.js.map +0 -1
- package/dist/generated/google/protobuf/descriptor.d.ts +0 -1204
- package/dist/generated/google/protobuf/descriptor.d.ts.map +0 -1
- package/dist/generated/google/protobuf/descriptor.js +0 -6676
- package/dist/generated/google/protobuf/descriptor.js.map +0 -1
- package/dist/generated/google/protobuf/empty.d.ts +0 -86
- package/dist/generated/google/protobuf/empty.d.ts.map +0 -1
- package/dist/generated/google/protobuf/empty.js +0 -107
- package/dist/generated/google/protobuf/empty.js.map +0 -1
- package/dist/generated/google/protobuf/struct.d.ts +0 -175
- package/dist/generated/google/protobuf/struct.d.ts.map +0 -1
- package/dist/generated/google/protobuf/struct.js +0 -754
- package/dist/generated/google/protobuf/struct.js.map +0 -1
- package/dist/generated/proto/discovery.d.ts +0 -105
- package/dist/generated/proto/discovery.d.ts.map +0 -1
- package/dist/generated/proto/discovery.js +0 -364
- package/dist/generated/proto/discovery.js.map +0 -1
- package/dist/generated/proto/dynrpc.d.ts +0 -150
- package/dist/generated/proto/dynrpc.d.ts.map +0 -1
- package/dist/generated/proto/dynrpc.js +0 -668
- package/dist/generated/proto/dynrpc.js.map +0 -1
- package/dist/generated/proto/javascript.d.ts +0 -110
- package/dist/generated/proto/javascript.d.ts.map +0 -1
- package/dist/generated/proto/javascript.js +0 -416
- package/dist/generated/proto/javascript.js.map +0 -1
- package/dist/generated/proto/protocol.d.ts +0 -450
- package/dist/generated/proto/protocol.d.ts.map +0 -1
- package/dist/generated/proto/protocol.js +0 -2641
- package/dist/generated/proto/protocol.js.map +0 -1
- package/dist/generated/proto/services.d.ts +0 -307
- package/dist/generated/proto/services.d.ts.map +0 -1
- package/dist/generated/proto/services.js +0 -1535
- package/dist/generated/proto/services.js.map +0 -1
- package/dist/generated/proto/test.d.ts +0 -116
- package/dist/generated/proto/test.d.ts.map +0 -1
- package/dist/generated/proto/test.js +0 -321
- package/dist/generated/proto/test.js.map +0 -1
- package/dist/invocation.d.ts.map +0 -1
- package/dist/invocation.js.map +0 -1
- package/dist/io/decoder.d.ts.map +0 -1
- package/dist/io/decoder.js.map +0 -1
- package/dist/io/encoder.d.ts.map +0 -1
- package/dist/io/encoder.js.map +0 -1
- package/dist/journal.d.ts.map +0 -1
- package/dist/journal.js.map +0 -1
- package/dist/local_state_store.d.ts.map +0 -1
- package/dist/local_state_store.js.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -90
- package/dist/logger.js.map +0 -1
- package/dist/promise_combinator_tracker.d.ts.map +0 -1
- package/dist/promise_combinator_tracker.js.map +0 -1
- package/dist/public_api.d.ts +0 -10
- package/dist/public_api.d.ts.map +0 -1
- package/dist/public_api.js.map +0 -1
- package/dist/state_machine.d.ts.map +0 -1
- package/dist/state_machine.js.map +0 -1
- package/dist/types/errors.d.ts +0 -188
- package/dist/types/errors.d.ts.map +0 -1
- package/dist/types/errors.js +0 -273
- package/dist/types/errors.js.map +0 -1
- package/dist/types/grpc.d.ts +0 -90
- package/dist/types/grpc.d.ts.map +0 -1
- package/dist/types/grpc.js +0 -81
- package/dist/types/grpc.js.map +0 -1
- package/dist/types/protocol.d.ts +0 -30
- package/dist/types/protocol.d.ts.map +0 -1
- package/dist/types/protocol.js.map +0 -1
- package/dist/types/router.d.ts +0 -33
- package/dist/types/router.d.ts.map +0 -1
- package/dist/types/router.js +0 -36
- package/dist/types/router.js.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/types.js.map +0 -1
- package/dist/utils/assumptions.d.ts +0 -8
- package/dist/utils/assumptions.d.ts.map +0 -1
- package/dist/utils/assumptions.js +0 -101
- package/dist/utils/assumptions.js.map +0 -1
- package/dist/utils/message_logger.d.ts +0 -28
- package/dist/utils/message_logger.d.ts.map +0 -1
- package/dist/utils/message_logger.js.map +0 -1
- package/dist/utils/promises.d.ts.map +0 -1
- package/dist/utils/promises.js.map +0 -1
- package/dist/utils/public_utils.d.ts +0 -58
- package/dist/utils/public_utils.d.ts.map +0 -1
- package/dist/utils/public_utils.js +0 -49
- package/dist/utils/public_utils.js.map +0 -1
- package/dist/utils/rand.d.ts.map +0 -1
- package/dist/utils/rand.js.map +0 -1
- package/dist/utils/utils.d.ts.map +0 -1
- package/dist/utils/utils.js.map +0 -1
- package/dist/workflows/workflow.d.ts.map +0 -1
- package/dist/workflows/workflow.js.map +0 -1
- package/dist/workflows/workflow_state_service.d.ts +0 -35
- package/dist/workflows/workflow_state_service.d.ts.map +0 -1
- package/dist/workflows/workflow_state_service.js.map +0 -1
- package/dist/workflows/workflow_wrapper_service.d.ts.map +0 -1
- package/dist/workflows/workflow_wrapper_service.js.map +0 -1
- package/src/clients/workflow_client.ts +0 -290
- package/src/connection/buffered_connection.ts +0 -47
- package/src/connection/connection.ts +0 -34
- package/src/connection/embedded_connection.ts +0 -62
- package/src/connection/http_connection.ts +0 -228
- package/src/connection/lambda_connection.ts +0 -69
- package/src/context.ts +0 -633
- package/src/context_impl.ts +0 -721
- package/src/embedded/api.ts +0 -57
- package/src/embedded/handler.ts +0 -36
- package/src/embedded/http2_remote.ts +0 -103
- package/src/embedded/invocation.ts +0 -126
- package/src/endpoint/endpoint_impl.ts +0 -623
- package/src/endpoint/http2_handler.ts +0 -151
- package/src/endpoint/lambda_handler.ts +0 -181
- package/src/endpoint.ts +0 -187
- package/src/generated/dev/restate/events.ts +0 -430
- package/src/generated/dev/restate/ext.ts +0 -238
- package/src/generated/google/protobuf/descriptor.ts +0 -7889
- package/src/generated/google/protobuf/empty.ts +0 -150
- package/src/generated/google/protobuf/struct.ts +0 -878
- package/src/generated/proto/discovery.ts +0 -423
- package/src/generated/proto/dynrpc.ts +0 -768
- package/src/generated/proto/javascript.ts +0 -488
- package/src/generated/proto/protocol.ts +0 -3091
- package/src/generated/proto/services.ts +0 -1834
- package/src/generated/proto/test.ts +0 -387
- package/src/invocation.ts +0 -212
- package/src/io/decoder.ts +0 -171
- package/src/io/encoder.ts +0 -72
- package/src/journal.ts +0 -537
- package/src/local_state_store.ts +0 -94
- package/src/logger.ts +0 -121
- package/src/promise_combinator_tracker.ts +0 -191
- package/src/public_api.ts +0 -53
- package/src/state_machine.ts +0 -635
- package/src/types/errors.ts +0 -297
- package/src/types/grpc.ts +0 -97
- package/src/types/protocol.ts +0 -201
- package/src/types/router.ts +0 -118
- package/src/types/types.ts +0 -160
- package/src/utils/assumptions.ts +0 -131
- package/src/utils/message_logger.ts +0 -112
- package/src/utils/promises.ts +0 -118
- package/src/utils/public_utils.ts +0 -91
- package/src/utils/rand.ts +0 -142
- package/src/utils/utils.ts +0 -178
- package/src/workflows/workflow.ts +0 -178
- package/src/workflows/workflow_state_service.ts +0 -299
- package/src/workflows/workflow_wrapper_service.ts +0 -314
- /package/dist/{connection → src/connection}/buffered_connection.js +0 -0
- /package/dist/{connection → src/connection}/connection.d.ts +0 -0
- /package/dist/{connection → src/connection}/connection.js +0 -0
- /package/dist/{promise_combinator_tracker.d.ts → src/promise_combinator_tracker.d.ts} +0 -0
- /package/dist/{promise_combinator_tracker.js → src/promise_combinator_tracker.js} +0 -0
- /package/dist/{utils → src/utils}/promises.d.ts +0 -0
- /package/dist/{utils → src/utils}/promises.js +0 -0
|
@@ -10,29 +10,26 @@
|
|
|
10
10
|
* https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.ContextImpl = exports.
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const async_hooks_1 = require("async_hooks");
|
|
13
|
+
exports.ContextImpl = exports.CallContextType = void 0;
|
|
14
|
+
const protocol_pb_1 = require("./generated/proto/protocol_pb");
|
|
15
|
+
const protocol_1 = require("./types/protocol");
|
|
16
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
18
17
|
const errors_1 = require("./types/errors");
|
|
19
18
|
const utils_1 = require("./utils/utils");
|
|
20
|
-
const
|
|
21
|
-
const dynrpc_1 = require("./generated/proto/dynrpc");
|
|
22
|
-
const assumptions_1 = require("./utils/assumptions");
|
|
19
|
+
const protobuf_1 = require("@bufbuild/protobuf");
|
|
23
20
|
const rand_1 = require("./utils/rand");
|
|
24
21
|
const promise_combinator_tracker_1 = require("./promise_combinator_tracker");
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
const node_buffer_1 = require("node:buffer");
|
|
23
|
+
const serde_1 = require("./utils/serde");
|
|
24
|
+
var CallContextType;
|
|
25
|
+
(function (CallContextType) {
|
|
26
|
+
CallContextType[CallContextType["None"] = 0] = "None";
|
|
27
|
+
CallContextType[CallContextType["Run"] = 1] = "Run";
|
|
28
|
+
})(CallContextType = exports.CallContextType || (exports.CallContextType = {}));
|
|
31
29
|
class ContextImpl {
|
|
32
|
-
id;
|
|
33
|
-
serviceName;
|
|
34
30
|
console;
|
|
35
31
|
keyedContext;
|
|
32
|
+
keyedContextKey;
|
|
36
33
|
stateMachine;
|
|
37
34
|
rand;
|
|
38
35
|
// here, we capture the context information for actions on the Restate context that
|
|
@@ -41,19 +38,41 @@ class ContextImpl {
|
|
|
41
38
|
// we also use this information to ensure we check that only allowed operations are
|
|
42
39
|
// used. Within side-effects, no operations are allowed on the RestateContext.
|
|
43
40
|
// For example, this is illegal: 'ctx.sideEffect(() => {await ctx.get("my-state")})'
|
|
44
|
-
static callContext = new
|
|
41
|
+
static callContext = new node_async_hooks_1.AsyncLocalStorage();
|
|
45
42
|
// This is used to guard users against calling ctx.sideEffect without awaiting it.
|
|
46
43
|
// See https://github.com/restatedev/sdk-typescript/issues/197 for more details.
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
executingRun = false;
|
|
45
|
+
invocationRequest;
|
|
46
|
+
date = {
|
|
47
|
+
now: () => {
|
|
48
|
+
return this.run(() => Date.now());
|
|
49
|
+
},
|
|
50
|
+
toJSON: () => {
|
|
51
|
+
return this.run(() => new Date().toJSON());
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
constructor(id, console, keyedContext, keyedContextKey, invocationValue, invocationHeaders,
|
|
49
55
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
56
|
stateMachine, rand = new rand_1.RandImpl(id)) {
|
|
51
|
-
this.id = id;
|
|
52
|
-
this.serviceName = serviceName;
|
|
53
57
|
this.console = console;
|
|
54
58
|
this.keyedContext = keyedContext;
|
|
59
|
+
this.keyedContextKey = keyedContextKey;
|
|
55
60
|
this.stateMachine = stateMachine;
|
|
56
61
|
this.rand = rand;
|
|
62
|
+
this.invocationRequest = {
|
|
63
|
+
id,
|
|
64
|
+
headers: invocationHeaders,
|
|
65
|
+
body: invocationValue,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
get key() {
|
|
69
|
+
if (!this.keyedContextKey) {
|
|
70
|
+
throw new errors_1.TerminalError("unexpected missing key");
|
|
71
|
+
}
|
|
72
|
+
return this.keyedContextKey;
|
|
73
|
+
}
|
|
74
|
+
request() {
|
|
75
|
+
return this.invocationRequest;
|
|
57
76
|
}
|
|
58
77
|
// DON'T make this function async!!! see sideEffect comment for details.
|
|
59
78
|
get(name) {
|
|
@@ -61,10 +80,10 @@ class ContextImpl {
|
|
|
61
80
|
this.checkState("get state");
|
|
62
81
|
this.checkStateOperation("get state");
|
|
63
82
|
// Create the message and let the state machine process it
|
|
64
|
-
const msg =
|
|
83
|
+
const msg = new protocol_pb_1.GetStateEntryMessage({ key: node_buffer_1.Buffer.from(name) });
|
|
65
84
|
const completed = this.stateMachine.localStateStore.tryCompleteGet(name, msg);
|
|
66
85
|
const getState = async () => {
|
|
67
|
-
const result = await this.stateMachine.handleUserCodeMessage(
|
|
86
|
+
const result = await this.stateMachine.handleUserCodeMessage(protocol_1.GET_STATE_ENTRY_MESSAGE_TYPE, msg, completed);
|
|
68
87
|
// If the GetState message did not have a value or empty,
|
|
69
88
|
// then we went to the runtime to get the value.
|
|
70
89
|
// When we get the response, we set it in the localStateStore,
|
|
@@ -72,7 +91,7 @@ class ContextImpl {
|
|
|
72
91
|
if (!completed) {
|
|
73
92
|
this.stateMachine.localStateStore.add(name, result);
|
|
74
93
|
}
|
|
75
|
-
if (!(result instanceof Buffer)) {
|
|
94
|
+
if (!(result instanceof node_buffer_1.Buffer)) {
|
|
76
95
|
return null;
|
|
77
96
|
}
|
|
78
97
|
return (0, utils_1.jsonDeserialize)(result.toString());
|
|
@@ -84,10 +103,10 @@ class ContextImpl {
|
|
|
84
103
|
// Check if this is a valid action
|
|
85
104
|
this.checkState("state keys");
|
|
86
105
|
// Create the message and let the state machine process it
|
|
87
|
-
const msg =
|
|
106
|
+
const msg = new protocol_pb_1.GetStateKeysEntryMessage({});
|
|
88
107
|
const completed = this.stateMachine.localStateStore.tryCompletedGetStateKeys(msg);
|
|
89
108
|
const getStateKeys = async () => {
|
|
90
|
-
const result = await this.stateMachine.handleUserCodeMessage(
|
|
109
|
+
const result = await this.stateMachine.handleUserCodeMessage(protocol_1.GET_STATE_KEYS_ENTRY_MESSAGE_TYPE, msg, completed);
|
|
91
110
|
return result.keys.map((b) => b.toString());
|
|
92
111
|
};
|
|
93
112
|
return getStateKeys();
|
|
@@ -96,133 +115,150 @@ class ContextImpl {
|
|
|
96
115
|
this.checkState("set state");
|
|
97
116
|
this.checkStateOperation("set state");
|
|
98
117
|
const msg = this.stateMachine.localStateStore.set(name, value);
|
|
99
|
-
this.stateMachine
|
|
118
|
+
this.stateMachine
|
|
119
|
+
.handleUserCodeMessage(protocol_1.SET_STATE_ENTRY_MESSAGE_TYPE, msg)
|
|
120
|
+
.catch((e) => this.stateMachine.handleDanglingPromiseError(e));
|
|
100
121
|
}
|
|
101
122
|
clear(name) {
|
|
102
123
|
this.checkState("clear state");
|
|
103
124
|
this.checkStateOperation("clear state");
|
|
104
125
|
const msg = this.stateMachine.localStateStore.clear(name);
|
|
105
|
-
this.stateMachine
|
|
126
|
+
this.stateMachine
|
|
127
|
+
.handleUserCodeMessage(protocol_1.CLEAR_STATE_ENTRY_MESSAGE_TYPE, msg)
|
|
128
|
+
.catch((e) => this.stateMachine.handleDanglingPromiseError(e));
|
|
106
129
|
}
|
|
107
130
|
clearAll() {
|
|
108
131
|
this.checkState("clear all state");
|
|
109
132
|
const msg = this.stateMachine.localStateStore.clearAll();
|
|
110
|
-
this.stateMachine
|
|
133
|
+
this.stateMachine
|
|
134
|
+
.handleUserCodeMessage(protocol_1.CLEAR_ALL_STATE_ENTRY_MESSAGE_TYPE, msg)
|
|
135
|
+
.catch((e) => this.stateMachine.handleDanglingPromiseError(e));
|
|
111
136
|
}
|
|
112
137
|
// --- Calls, background calls, etc
|
|
113
|
-
request(service, method, data) {
|
|
114
|
-
if (this.isInOneWayCall()) {
|
|
115
|
-
return this.invokeOneWay(service, method, data, this.getOneWayCallDelay());
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
return this.invoke(service, method, data);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
138
|
// DON'T make this function async!!! see sideEffect comment for details.
|
|
122
|
-
invoke(service, method, data) {
|
|
139
|
+
invoke(service, method, data, key) {
|
|
123
140
|
this.checkState("invoke");
|
|
124
|
-
const msg =
|
|
141
|
+
const msg = new protocol_pb_1.CallEntryMessage({
|
|
125
142
|
serviceName: service,
|
|
126
|
-
|
|
127
|
-
parameter: Buffer.from(data),
|
|
143
|
+
handlerName: method,
|
|
144
|
+
parameter: node_buffer_1.Buffer.from(data),
|
|
145
|
+
key,
|
|
128
146
|
});
|
|
129
147
|
return this.markCombineablePromise(this.stateMachine
|
|
130
|
-
.handleUserCodeMessage(
|
|
148
|
+
.handleUserCodeMessage(protocol_1.INVOKE_ENTRY_MESSAGE_TYPE, msg)
|
|
131
149
|
.transform((v) => v));
|
|
132
150
|
}
|
|
133
|
-
async invokeOneWay(service, method, data, delay) {
|
|
151
|
+
async invokeOneWay(service, method, data, delay, key) {
|
|
134
152
|
const actualDelay = delay || 0;
|
|
135
|
-
const invokeTime = actualDelay > 0 ? Date.now() + actualDelay :
|
|
136
|
-
const msg =
|
|
153
|
+
const invokeTime = actualDelay > 0 ? Date.now() + actualDelay : protobuf_1.protoInt64.zero;
|
|
154
|
+
const msg = new protocol_pb_1.OneWayCallEntryMessage({
|
|
137
155
|
serviceName: service,
|
|
138
|
-
|
|
139
|
-
parameter: Buffer.from(data),
|
|
140
|
-
invokeTime: invokeTime,
|
|
156
|
+
handlerName: method,
|
|
157
|
+
parameter: node_buffer_1.Buffer.from(data),
|
|
158
|
+
invokeTime: protobuf_1.protoInt64.parse(invokeTime),
|
|
159
|
+
key,
|
|
141
160
|
});
|
|
142
|
-
await this.stateMachine.handleUserCodeMessage(
|
|
161
|
+
await this.stateMachine.handleUserCodeMessage(protocol_1.BACKGROUND_INVOKE_ENTRY_MESSAGE_TYPE, msg);
|
|
143
162
|
return new Uint8Array();
|
|
144
163
|
}
|
|
145
|
-
|
|
146
|
-
oneWayCall(
|
|
147
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
148
|
-
call) {
|
|
149
|
-
this.checkState("oneWayCall");
|
|
150
|
-
return ContextImpl.callContext.run({ type: CallContexType.OneWayCall }, call);
|
|
151
|
-
}
|
|
152
|
-
// DON'T make this function async!!! see sideEffect comment for details.
|
|
153
|
-
delayedCall(
|
|
154
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
155
|
-
call, delayMillis) {
|
|
156
|
-
this.checkState("delayedCall");
|
|
157
|
-
// Delayed call is a one way call with a delay
|
|
158
|
-
return ContextImpl.callContext.run({ type: CallContexType.OneWayCall, delay: delayMillis }, call);
|
|
159
|
-
}
|
|
160
|
-
rpc({ path }) {
|
|
164
|
+
serviceClient({ name, }) {
|
|
161
165
|
const clientProxy = new Proxy({}, {
|
|
162
166
|
get: (_target, prop) => {
|
|
163
167
|
const route = prop;
|
|
164
|
-
return
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
return this.invoke(path, route, requestBytes).transform((responseBytes) => dynrpc_1.RpcResponse.decode(responseBytes).response);
|
|
168
|
+
return (...args) => {
|
|
169
|
+
const requestBytes = (0, serde_1.serializeJson)(args.shift());
|
|
170
|
+
return this.invoke(name, route, requestBytes).transform((responseBytes) => (0, serde_1.deserializeJson)(responseBytes));
|
|
168
171
|
};
|
|
169
172
|
},
|
|
170
173
|
});
|
|
171
174
|
return clientProxy;
|
|
172
175
|
}
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
objectClient({ name }, key) {
|
|
177
|
+
const clientProxy = new Proxy({}, {
|
|
178
|
+
get: (_target, prop) => {
|
|
179
|
+
const route = prop;
|
|
180
|
+
return (...args) => {
|
|
181
|
+
const requestBytes = (0, serde_1.serializeJson)(args.shift());
|
|
182
|
+
return this.invoke(name, route, requestBytes, key).transform((responseBytes) => (0, serde_1.deserializeJson)(responseBytes));
|
|
183
|
+
};
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
return clientProxy;
|
|
175
187
|
}
|
|
176
|
-
|
|
188
|
+
serviceSendClient(service, opts) {
|
|
177
189
|
const clientProxy = new Proxy({}, {
|
|
178
190
|
get: (_target, prop) => {
|
|
179
191
|
const route = prop;
|
|
180
192
|
return (...args) => {
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
193
|
+
const requestBytes = (0, serde_1.serializeJson)(args.shift());
|
|
194
|
+
this.invokeOneWay(service.name, route, requestBytes, opts?.delay).catch((e) => {
|
|
195
|
+
this.stateMachine.handleDanglingPromiseError(e);
|
|
196
|
+
});
|
|
184
197
|
};
|
|
185
198
|
},
|
|
186
199
|
});
|
|
187
200
|
return clientProxy;
|
|
188
201
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
202
|
+
objectSendClient(obj, key, opts) {
|
|
203
|
+
const clientProxy = new Proxy({}, {
|
|
204
|
+
get: (_target, prop) => {
|
|
205
|
+
const route = prop;
|
|
206
|
+
return (...args) => {
|
|
207
|
+
const requestBytes = (0, serde_1.serializeJson)(args.shift());
|
|
208
|
+
this.invokeOneWay(obj.name, route, requestBytes, opts?.delay, key).catch((e) => {
|
|
209
|
+
this.stateMachine.handleDanglingPromiseError(e);
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
return clientProxy;
|
|
192
215
|
}
|
|
193
216
|
// DON'T make this function async!!!
|
|
194
|
-
// The reason is that we want the
|
|
217
|
+
// The reason is that we want the errors thrown by the initial checks to be propagated in the caller context,
|
|
195
218
|
// and not in the promise context. To understand the semantic difference, make this function async and run the
|
|
196
219
|
// UnawaitedSideEffectShouldFailSubsequentContextCall test.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
"Context method ctx.oneWayCall() can only be used to invoke other services unidirectionally. " +
|
|
204
|
-
"e.g. ctx.oneWayCall(() => client.greet(my_request))", { errorCode: errors_1.ErrorCodes.INTERNAL });
|
|
220
|
+
run(nameOrAction, actionSecondParameter) {
|
|
221
|
+
const { name, action } = unpack(nameOrAction, actionSecondParameter);
|
|
222
|
+
if (this.isInRun()) {
|
|
223
|
+
throw new errors_1.TerminalError("Not possible to nest runs.", {
|
|
224
|
+
errorCode: errors_1.INTERNAL_ERROR_CODE,
|
|
225
|
+
});
|
|
205
226
|
}
|
|
206
|
-
this.
|
|
207
|
-
this.
|
|
208
|
-
const
|
|
227
|
+
this.checkNotExecutingRun();
|
|
228
|
+
this.executingRun = true;
|
|
229
|
+
const executeRun = async () => {
|
|
209
230
|
// in replay mode, we directly return the value from the log
|
|
210
231
|
if (this.stateMachine.nextEntryWillBeReplayed()) {
|
|
211
|
-
const emptyMsg =
|
|
212
|
-
return this.stateMachine.handleUserCodeMessage(
|
|
232
|
+
const emptyMsg = new protocol_pb_1.RunEntryMessage({});
|
|
233
|
+
return this.stateMachine.handleUserCodeMessage(protocol_1.SIDE_EFFECT_ENTRY_MESSAGE_TYPE, emptyMsg);
|
|
213
234
|
}
|
|
214
235
|
let sideEffectResult;
|
|
215
236
|
try {
|
|
216
|
-
sideEffectResult = await ContextImpl.callContext.run({ type:
|
|
237
|
+
sideEffectResult = await ContextImpl.callContext.run({ type: CallContextType.Run }, () => action());
|
|
217
238
|
}
|
|
218
239
|
catch (e) {
|
|
219
|
-
|
|
240
|
+
if (!(e instanceof errors_1.TerminalError)) {
|
|
241
|
+
///non terminal errors are retirable.
|
|
242
|
+
// we do not commit the error itself into the journal, but rather let restate know about this
|
|
243
|
+
// so that restate can retry this invocation later.
|
|
244
|
+
// Before we can propagate this error to the user, we must let the state machine know that this attempt
|
|
245
|
+
// is finished with an error, and it should not append anything else to the journal from now on.
|
|
246
|
+
const error = (0, errors_1.ensureError)(e);
|
|
247
|
+
const additionalContext = {
|
|
248
|
+
relatedEntryName: name,
|
|
249
|
+
relatedEntryType: protocol_1.SIDE_EFFECT_ENTRY_MESSAGE_TYPE,
|
|
250
|
+
};
|
|
251
|
+
await this.stateMachine.sendErrorAndFinish(error, additionalContext);
|
|
252
|
+
throw e;
|
|
253
|
+
}
|
|
254
|
+
// we commit a terminal error from the side effect to the journal, and re-throw it into
|
|
220
255
|
// the function. that way, any catching by the user and reacting to it will be
|
|
221
256
|
// deterministic on replay
|
|
222
257
|
const error = (0, errors_1.ensureError)(e);
|
|
223
|
-
const failure = (0, errors_1.
|
|
224
|
-
const sideEffectMsg =
|
|
225
|
-
|
|
258
|
+
const failure = (0, errors_1.errorToFailure)(error);
|
|
259
|
+
const sideEffectMsg = new protocol_pb_1.RunEntryMessage({
|
|
260
|
+
name,
|
|
261
|
+
result: { case: "failure", value: failure },
|
|
226
262
|
});
|
|
227
263
|
// this may throw an error from the SDK/runtime/connection side, in case the
|
|
228
264
|
// failure message cannot be committed to the journal. That error would then
|
|
@@ -230,16 +266,22 @@ class ContextImpl {
|
|
|
230
266
|
// that is acceptable, because in such a situation (failure to append to journal),
|
|
231
267
|
// the state machine closes anyways and no further operations will succeed and the
|
|
232
268
|
// the execution aborts
|
|
233
|
-
await this.stateMachine.handleUserCodeMessage(
|
|
269
|
+
await this.stateMachine.handleUserCodeMessage(protocol_1.SIDE_EFFECT_ENTRY_MESSAGE_TYPE, sideEffectMsg, false, undefined, true);
|
|
234
270
|
throw e;
|
|
235
271
|
}
|
|
236
272
|
// we have this code outside the above try/catch block, to ensure that any error arising
|
|
237
273
|
// from here is not incorrectly attributed to the side-effect
|
|
238
274
|
const sideEffectMsg = sideEffectResult !== undefined
|
|
239
|
-
?
|
|
240
|
-
|
|
275
|
+
? new protocol_pb_1.RunEntryMessage({
|
|
276
|
+
name,
|
|
277
|
+
result: {
|
|
278
|
+
case: "value",
|
|
279
|
+
value: node_buffer_1.Buffer.from((0, utils_1.jsonSerialize)(sideEffectResult)),
|
|
280
|
+
},
|
|
241
281
|
})
|
|
242
|
-
:
|
|
282
|
+
: new protocol_pb_1.RunEntryMessage({
|
|
283
|
+
name,
|
|
284
|
+
});
|
|
243
285
|
// if an error arises from committing the side effect result, then this error will
|
|
244
286
|
// be thrown here (reject the returned promise) and the function will see that error,
|
|
245
287
|
// even if the side-effect function completed correctly
|
|
@@ -250,12 +292,11 @@ class ContextImpl {
|
|
|
250
292
|
// re-executes, and if it made it to the journal after all (error happend inly during
|
|
251
293
|
// ack-back), then retries will use the journaled result.
|
|
252
294
|
// So all good in any case, due to the beauty of "the runtime log is the ground thruth" approach.
|
|
253
|
-
await this.stateMachine.handleUserCodeMessage(
|
|
295
|
+
await this.stateMachine.handleUserCodeMessage(protocol_1.SIDE_EFFECT_ENTRY_MESSAGE_TYPE, sideEffectMsg, false, undefined, true);
|
|
254
296
|
return sideEffectResult;
|
|
255
297
|
};
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
this.executingSideEffect = false;
|
|
298
|
+
return executeRun().finally(() => {
|
|
299
|
+
this.executingRun = false;
|
|
259
300
|
});
|
|
260
301
|
}
|
|
261
302
|
sleep(millis) {
|
|
@@ -263,16 +304,18 @@ class ContextImpl {
|
|
|
263
304
|
return this.markCombineablePromise(this.sleepInternal(millis));
|
|
264
305
|
}
|
|
265
306
|
sleepInternal(millis) {
|
|
266
|
-
return this.stateMachine.handleUserCodeMessage(
|
|
307
|
+
return this.stateMachine.handleUserCodeMessage(protocol_1.SLEEP_ENTRY_MESSAGE_TYPE, new protocol_pb_1.SleepEntryMessage({
|
|
308
|
+
wakeUpTime: protobuf_1.protoInt64.parse(Date.now() + millis),
|
|
309
|
+
}));
|
|
267
310
|
}
|
|
268
311
|
// -- Awakeables
|
|
269
312
|
awakeable() {
|
|
270
313
|
this.checkState("awakeable");
|
|
271
|
-
const msg =
|
|
314
|
+
const msg = new protocol_pb_1.AwakeableEntryMessage();
|
|
272
315
|
const promise = this.stateMachine
|
|
273
|
-
.handleUserCodeMessage(
|
|
316
|
+
.handleUserCodeMessage(protocol_1.AWAKEABLE_ENTRY_MESSAGE_TYPE, msg)
|
|
274
317
|
.transform((result) => {
|
|
275
|
-
if (!(result instanceof Buffer)) {
|
|
318
|
+
if (!(result instanceof node_buffer_1.Buffer)) {
|
|
276
319
|
// This should either be a filled buffer or an empty buffer but never anything else.
|
|
277
320
|
throw errors_1.RetryableError.internal("Awakeable was not resolved with a buffer payload");
|
|
278
321
|
}
|
|
@@ -280,11 +323,11 @@ class ContextImpl {
|
|
|
280
323
|
});
|
|
281
324
|
// This needs to be done after handling the message in the state machine
|
|
282
325
|
// otherwise the index is not yet incremented.
|
|
283
|
-
const encodedEntryIndex = Buffer.alloc(4 /* Size of u32 */);
|
|
326
|
+
const encodedEntryIndex = node_buffer_1.Buffer.alloc(4 /* Size of u32 */);
|
|
284
327
|
encodedEntryIndex.writeUInt32BE(this.stateMachine.getUserCodeJournalIndex());
|
|
285
328
|
return {
|
|
286
|
-
id:
|
|
287
|
-
Buffer.concat([this.id, encodedEntryIndex]).toString("base64url"),
|
|
329
|
+
id: protocol_1.AWAKEABLE_IDENTIFIER_PREFIX +
|
|
330
|
+
node_buffer_1.Buffer.concat([this.request().id, encodedEntryIndex]).toString("base64url"),
|
|
288
331
|
promise: this.markCombineablePromise(promise),
|
|
289
332
|
};
|
|
290
333
|
}
|
|
@@ -293,24 +336,36 @@ class ContextImpl {
|
|
|
293
336
|
const payloadToWrite = payload === undefined ? null : payload;
|
|
294
337
|
this.checkState("resolveAwakeable");
|
|
295
338
|
this.completeAwakeable(id, {
|
|
296
|
-
|
|
339
|
+
result: {
|
|
340
|
+
case: "value",
|
|
341
|
+
value: node_buffer_1.Buffer.from(JSON.stringify(payloadToWrite)),
|
|
342
|
+
},
|
|
297
343
|
});
|
|
298
344
|
}
|
|
299
345
|
rejectAwakeable(id, reason) {
|
|
300
346
|
this.checkState("rejectAwakeable");
|
|
301
347
|
this.completeAwakeable(id, {
|
|
302
|
-
|
|
348
|
+
result: {
|
|
349
|
+
case: "failure",
|
|
350
|
+
value: { code: errors_1.UNKNOWN_ERROR_CODE, message: reason },
|
|
351
|
+
},
|
|
303
352
|
});
|
|
304
353
|
}
|
|
305
354
|
completeAwakeable(id, base) {
|
|
306
355
|
base.id = id;
|
|
307
|
-
this.stateMachine
|
|
356
|
+
this.stateMachine
|
|
357
|
+
.handleUserCodeMessage(protocol_1.COMPLETE_AWAKEABLE_ENTRY_MESSAGE_TYPE, new protocol_pb_1.CompleteAwakeableEntryMessage(base))
|
|
358
|
+
.catch((e) => this.stateMachine.handleDanglingPromiseError(e));
|
|
308
359
|
}
|
|
309
360
|
// Used by static methods of CombineablePromise
|
|
310
|
-
createCombinator(combinatorConstructor, promises) {
|
|
361
|
+
static createCombinator(combinatorConstructor, promises) {
|
|
362
|
+
const self = extractContext(promises[0]);
|
|
363
|
+
if (!self) {
|
|
364
|
+
throw errors_1.RetryableError.internal("Not a combinable promise");
|
|
365
|
+
}
|
|
311
366
|
const outPromises = [];
|
|
312
367
|
for (const promise of promises) {
|
|
313
|
-
if (promise
|
|
368
|
+
if (extractContext(promise) !== self) {
|
|
314
369
|
throw errors_1.RetryableError.internal("You're mixing up CombineablePromises from different RestateContext. This is not supported.");
|
|
315
370
|
}
|
|
316
371
|
const index = promise
|
|
@@ -320,45 +375,32 @@ class ContextImpl {
|
|
|
320
375
|
promise: promise,
|
|
321
376
|
});
|
|
322
377
|
}
|
|
323
|
-
return
|
|
378
|
+
return self.stateMachine.createCombinator(combinatorConstructor, outPromises);
|
|
324
379
|
}
|
|
325
380
|
// -- Various private methods
|
|
326
|
-
|
|
327
|
-
const context = ContextImpl.callContext.getStore();
|
|
328
|
-
return context?.type === CallContexType.SideEffect;
|
|
329
|
-
}
|
|
330
|
-
isInOneWayCall() {
|
|
331
|
-
const context = ContextImpl.callContext.getStore();
|
|
332
|
-
return context?.type === CallContexType.OneWayCall;
|
|
333
|
-
}
|
|
334
|
-
getOneWayCallDelay() {
|
|
381
|
+
isInRun() {
|
|
335
382
|
const context = ContextImpl.callContext.getStore();
|
|
336
|
-
return context?.
|
|
383
|
+
return context?.type === CallContextType.Run;
|
|
337
384
|
}
|
|
338
|
-
|
|
339
|
-
if (this.
|
|
340
|
-
throw new errors_1.TerminalError(`Invoked a RestateContext method while a
|
|
341
|
-
Make sure you await the ctx.
|
|
385
|
+
checkNotExecutingRun() {
|
|
386
|
+
if (this.executingRun) {
|
|
387
|
+
throw new errors_1.TerminalError(`Invoked a RestateContext method while a run() is still executing.
|
|
388
|
+
Make sure you await the ctx.run() call before using any other RestateContext method.`, { errorCode: errors_1.INTERNAL_ERROR_CODE });
|
|
342
389
|
}
|
|
343
390
|
}
|
|
344
391
|
checkState(callType) {
|
|
345
392
|
const context = ContextImpl.callContext.getStore();
|
|
346
393
|
if (!context) {
|
|
347
|
-
this.
|
|
394
|
+
this.checkNotExecutingRun();
|
|
348
395
|
return;
|
|
349
396
|
}
|
|
350
|
-
if (context.type ===
|
|
351
|
-
throw new errors_1.TerminalError(`You cannot do ${callType} calls from within a
|
|
352
|
-
}
|
|
353
|
-
if (context.type === CallContexType.OneWayCall) {
|
|
354
|
-
throw new errors_1.TerminalError(`Cannot do a ${callType} from within ctx.oneWayCall(...).
|
|
355
|
-
Context method oneWayCall() can only be used to invoke other services in the background.
|
|
356
|
-
e.g. ctx.oneWayCall(() => client.greet(my_request))`, { errorCode: errors_1.ErrorCodes.INTERNAL });
|
|
397
|
+
if (context.type === CallContextType.Run) {
|
|
398
|
+
throw new errors_1.TerminalError(`You cannot do ${callType} calls from within a run.`, { errorCode: errors_1.INTERNAL_ERROR_CODE });
|
|
357
399
|
}
|
|
358
400
|
}
|
|
359
401
|
checkStateOperation(callType) {
|
|
360
402
|
if (!this.keyedContext) {
|
|
361
|
-
throw new errors_1.TerminalError(`You can do ${callType} calls only from
|
|
403
|
+
throw new errors_1.TerminalError(`You can do ${callType} calls only from a virtual object`, { errorCode: errors_1.INTERNAL_ERROR_CODE });
|
|
362
404
|
}
|
|
363
405
|
}
|
|
364
406
|
markCombineablePromise(p) {
|
|
@@ -380,7 +422,7 @@ class ContextImpl {
|
|
|
380
422
|
]);
|
|
381
423
|
};
|
|
382
424
|
return Object.defineProperties(p, {
|
|
383
|
-
|
|
425
|
+
[RESTATE_CTX_SYMBOL]: {
|
|
384
426
|
value: this,
|
|
385
427
|
},
|
|
386
428
|
journalIndex: {
|
|
@@ -393,47 +435,24 @@ class ContextImpl {
|
|
|
393
435
|
}
|
|
394
436
|
}
|
|
395
437
|
exports.ContextImpl = ContextImpl;
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
// eslint-disable-next-line no-constant-condition
|
|
401
|
-
while (true) {
|
|
402
|
-
try {
|
|
403
|
-
return await executeAndLogSideEffect();
|
|
438
|
+
function unpack(a, b) {
|
|
439
|
+
if (typeof a == "string") {
|
|
440
|
+
if (typeof b !== "function") {
|
|
441
|
+
throw new TypeError("");
|
|
404
442
|
}
|
|
405
|
-
|
|
406
|
-
if (e instanceof errors_1.TerminalError) {
|
|
407
|
-
throw e;
|
|
408
|
-
}
|
|
409
|
-
// journal mismatch errors are special:
|
|
410
|
-
// - they are not terminal errors, because we want to allow pushing new code so
|
|
411
|
-
// that retries succeed later
|
|
412
|
-
// - they are not retried within the service, because they will never succeed within this service,
|
|
413
|
-
// but can only succeed within a new invocation going to service with fixed code
|
|
414
|
-
// we hence break the retries here similar to terminal errors
|
|
415
|
-
if (e instanceof errors_1.RestateError &&
|
|
416
|
-
e.code == errors_1.RestateErrorCodes.JOURNAL_MISMATCH) {
|
|
417
|
-
throw e;
|
|
418
|
-
}
|
|
419
|
-
const error = (0, errors_1.ensureError)(e);
|
|
420
|
-
console.debug("Error while executing side effect '%s': %s - %s", name, error.name, error.message);
|
|
421
|
-
if (error.stack) {
|
|
422
|
-
console.debug(error.stack);
|
|
423
|
-
}
|
|
424
|
-
if (retriesLeft > 0) {
|
|
425
|
-
console.debug("Retrying in %d ms", currentDelayMs);
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
-
console.debug("No retries left.");
|
|
429
|
-
throw new errors_1.TerminalError(`Retries exhausted for ${name}. Last error: ${error.name}: ${error.message}`, {
|
|
430
|
-
errorCode: errors_1.ErrorCodes.INTERNAL,
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
await sleep(currentDelayMs);
|
|
435
|
-
retriesLeft -= 1;
|
|
436
|
-
currentDelayMs = Math.min(policy.computeNextDelay(currentDelayMs), maxDelayMs);
|
|
443
|
+
return { name: a, action: b };
|
|
437
444
|
}
|
|
445
|
+
if (typeof a !== "function") {
|
|
446
|
+
throw new TypeError("unexpected type at the first parameter");
|
|
447
|
+
}
|
|
448
|
+
if (b) {
|
|
449
|
+
throw new TypeError("unexpected a function as a second parameter.");
|
|
450
|
+
}
|
|
451
|
+
return { action: a };
|
|
452
|
+
}
|
|
453
|
+
const RESTATE_CTX_SYMBOL = Symbol("restateContext");
|
|
454
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
455
|
+
function extractContext(n) {
|
|
456
|
+
return n[RESTATE_CTX_SYMBOL];
|
|
438
457
|
}
|
|
439
458
|
//# sourceMappingURL=context_impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context_impl.js","sourceRoot":"","sources":["../../src/context_impl.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAYH,+DAWuC;AACvC,+CAa0B;AAC1B,uDAAqD;AACrD,2CAQwB;AACxB,yCAA+D;AAC/D,iDAAgE;AAEhE,uCAAwC;AACxC,6EAAwE;AAExE,6CAAqC;AACrC,yCAA+D;AAE/D,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,qDAAI,CAAA;IACJ,mDAAG,CAAA;AACL,CAAC,EAHW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAG1B;AAYD,MAA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