@restatedev/restate-sdk 0.8.0 → 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 +3 -3
- package/dist/src/endpoint/lambda_handler.d.ts.map +1 -0
- package/dist/src/endpoint/lambda_handler.js +154 -0
- 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 +0 -144
- 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 -178
- 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
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { Client, SendClient, ServiceDefinition, VirtualObjectDefinition } from "./types/rpc";
|
|
4
|
+
/**
|
|
5
|
+
* Represents the original request as sent to this handler.
|
|
6
|
+
*
|
|
7
|
+
* A request object includes the request headers, and the raw unparsed
|
|
8
|
+
* request body.
|
|
9
|
+
*/
|
|
10
|
+
export interface Request {
|
|
11
|
+
/**
|
|
12
|
+
* The unique id that identifies the current function invocation. This id is guaranteed to be
|
|
13
|
+
* unique across invocations, but constant across reties and suspensions.
|
|
14
|
+
*/
|
|
15
|
+
readonly id: Buffer;
|
|
16
|
+
/**
|
|
17
|
+
* Request headers
|
|
18
|
+
*/
|
|
19
|
+
readonly headers: ReadonlyMap<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* Raw unparsed request body
|
|
22
|
+
*/
|
|
23
|
+
readonly body: Uint8Array;
|
|
24
|
+
}
|
|
5
25
|
/**
|
|
6
26
|
* Key value store operations. Only keyed services have an attached key-value store.
|
|
7
27
|
*/
|
|
@@ -15,7 +35,6 @@ export interface KeyValueStore {
|
|
|
15
35
|
* @returns a Promise that is resolved with the value of the state key
|
|
16
36
|
*
|
|
17
37
|
* @example
|
|
18
|
-
* const ctx = restate.useContext(this);
|
|
19
38
|
* const state = await ctx.get<string>("STATE");
|
|
20
39
|
*/
|
|
21
40
|
get<T>(name: string): Promise<T | null>;
|
|
@@ -29,7 +48,6 @@ export interface KeyValueStore {
|
|
|
29
48
|
* @param value value to set
|
|
30
49
|
*
|
|
31
50
|
* @example
|
|
32
|
-
* const ctx = restate.useContext(this);
|
|
33
51
|
* ctx.set("STATE", "Hello");
|
|
34
52
|
*/
|
|
35
53
|
set<T>(name: string, value: T): void;
|
|
@@ -38,7 +56,6 @@ export interface KeyValueStore {
|
|
|
38
56
|
* @param name key of the state to delete
|
|
39
57
|
*
|
|
40
58
|
* @example
|
|
41
|
-
* const ctx = restate.useContext(this);
|
|
42
59
|
* ctx.clear("STATE");
|
|
43
60
|
*/
|
|
44
61
|
clear(name: string): void;
|
|
@@ -46,40 +63,76 @@ export interface KeyValueStore {
|
|
|
46
63
|
* Clear/delete all the state entries in the Restate runtime.
|
|
47
64
|
*
|
|
48
65
|
* @example
|
|
49
|
-
* const ctx = restate.useContext(this);
|
|
50
66
|
* ctx.clearAll();
|
|
51
67
|
*/
|
|
52
68
|
clearAll(): void;
|
|
53
69
|
}
|
|
70
|
+
export interface SendOptions {
|
|
71
|
+
/**
|
|
72
|
+
* Makes a type-safe one-way RPC to the specified target service, after a delay specified by the
|
|
73
|
+
* milliseconds' argument.
|
|
74
|
+
* This method is like setting up a fault-tolerant cron job that enqueues the message in a
|
|
75
|
+
* message queue.
|
|
76
|
+
* The handler calling this function does not have to stay active for the delay time.
|
|
77
|
+
*
|
|
78
|
+
* Both the delay timer and the message are durably stored in Restate and guaranteed to be reliably
|
|
79
|
+
* delivered. The delivery happens no earlier than specified through the delay, but may happen
|
|
80
|
+
* later, if the target service is down, or backpressuring the system.
|
|
81
|
+
*
|
|
82
|
+
* The delay message is journaled for durable execution and will thus not be duplicated when the
|
|
83
|
+
* handler is re-invoked for retries or after suspending.
|
|
84
|
+
*
|
|
85
|
+
* This call will return immediately; the message sending happens asynchronously in the background.
|
|
86
|
+
* Despite that, the message is guaranteed to be sent, because the completion of the invocation that
|
|
87
|
+
* triggers the send (calls this function) happens logically after the sending. That means that any
|
|
88
|
+
* failure where the message does not reach Restate also cannot complete this invocation, and will
|
|
89
|
+
* hence recover this handler and (through the durable execution) recover the message to be sent.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* *Service Side:*
|
|
93
|
+
* ```ts
|
|
94
|
+
* const service = restate.service({
|
|
95
|
+
* ...
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* ```
|
|
99
|
+
* **Client side:**
|
|
100
|
+
* ```ts
|
|
101
|
+
* ctx.send(service, {delay: 60_000}).anotherAction(1337);
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
delay?: number;
|
|
105
|
+
}
|
|
106
|
+
export interface ContextDate {
|
|
107
|
+
/** Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).
|
|
108
|
+
* This is equivalent to Date.now()
|
|
109
|
+
*/
|
|
110
|
+
now(): Promise<number>;
|
|
111
|
+
/** Returns the JSON represention of the current date.
|
|
112
|
+
* This is equivalent to new Date().toJSON()
|
|
113
|
+
**/
|
|
114
|
+
toJSON(): Promise<string>;
|
|
115
|
+
}
|
|
116
|
+
export type RunAction<T> = (() => Promise<T>) | (() => T);
|
|
54
117
|
/**
|
|
55
118
|
* The context that gives access to all Restate-backed operations, for example
|
|
56
119
|
* - sending reliable messages / RPC through Restate
|
|
57
|
-
* -
|
|
120
|
+
* - execute non-deterministic closures and memoize their result
|
|
58
121
|
* - sleeps and delayed calls
|
|
59
122
|
* - awakeables
|
|
60
123
|
* - ...
|
|
61
124
|
*
|
|
62
|
-
*
|
|
125
|
+
* Virtual objects can also access their key-value store using the {@link ObjectContext}.
|
|
63
126
|
*
|
|
64
|
-
* In gRPC-based API, to access this context, use {@link useContext}.
|
|
65
127
|
*/
|
|
66
128
|
export interface Context {
|
|
67
|
-
/**
|
|
68
|
-
* The unique id that identifies the current function invocation. This id is guaranteed to be
|
|
69
|
-
* unique across invocations, but constant across reties and suspensions.
|
|
70
|
-
*/
|
|
71
|
-
id: Buffer;
|
|
72
|
-
/**
|
|
73
|
-
* Name of the service.
|
|
74
|
-
*/
|
|
75
|
-
serviceName: string;
|
|
76
129
|
/**
|
|
77
130
|
* Deterministic random methods; these are inherently predictable (seeded on the invocation ID, which is not secret)
|
|
78
131
|
* and so should not be used for any cryptographic purposes. They are useful for identifiers, idempotency keys,
|
|
79
132
|
* and for uniform sampling from a set of options. If a cryptographically secure value is needed, please generate that
|
|
80
133
|
* externally and capture the result with a side effect.
|
|
81
134
|
*
|
|
82
|
-
* Calls to these methods from inside
|
|
135
|
+
* Calls to these methods from inside `ctx.run` are disallowed and will fail - side effects must be idempotent, and
|
|
83
136
|
* these calls are not.
|
|
84
137
|
*/
|
|
85
138
|
rand: Rand;
|
|
@@ -89,47 +142,54 @@ export interface Context {
|
|
|
89
142
|
*/
|
|
90
143
|
console: Console;
|
|
91
144
|
/**
|
|
92
|
-
*
|
|
93
|
-
|
|
145
|
+
* Deterministic date.
|
|
146
|
+
*/
|
|
147
|
+
date: ContextDate;
|
|
148
|
+
/**
|
|
149
|
+
* Run an operation and store the result in Restate. The operation will thus not
|
|
150
|
+
* be re-run during a later replay, but take the durable result from Restate.
|
|
94
151
|
*
|
|
95
|
-
*
|
|
152
|
+
* This let you capture potentially non-deterministic computation and interaction
|
|
96
153
|
* with external systems in a safe way.
|
|
97
154
|
*
|
|
98
|
-
* Failure semantics
|
|
99
|
-
* - If
|
|
155
|
+
* Failure semantics are:
|
|
156
|
+
* - If an operation has run and persisted before, the result (value or Error) will be
|
|
100
157
|
* taken from the Restate journal.
|
|
101
|
-
* - There is a small window where
|
|
102
|
-
* occurred between
|
|
103
|
-
* - No second
|
|
104
|
-
* yet durable. That way,
|
|
105
|
-
* deterministic results from previous
|
|
158
|
+
* - There is a small window where an action may be re-run, if a failure
|
|
159
|
+
* occurred between a successful run and persisting the result.
|
|
160
|
+
* - No second action will be run while a previous run's result is not
|
|
161
|
+
* yet durable. That way, effects that build on top of each other can assume
|
|
162
|
+
* deterministic results from previous runs, and at most one run will be
|
|
106
163
|
* re-executed on replay (the latest, if the failure happened in the small windows
|
|
107
164
|
* described above).
|
|
108
165
|
*
|
|
109
|
-
* This function takes an optional retry policy, that determines what happens if the
|
|
110
|
-
* side effect throws an error. The default retry policy retries infinitely, with exponential
|
|
111
|
-
* backoff and uses suspending sleep for the wait times between retries.
|
|
112
|
-
*
|
|
113
166
|
* @example
|
|
114
|
-
* const
|
|
115
|
-
* const result = await ctx.sideEffect(async () => someExternalAction() )
|
|
167
|
+
* const result = await ctx.run(someExternalAction)
|
|
116
168
|
*
|
|
117
169
|
* @example
|
|
118
170
|
* const paymentAction = async () => {
|
|
119
171
|
* const result = await paymentClient.call(txId, methodIdentifier, amount);
|
|
120
|
-
* if (result.
|
|
121
|
-
* throw result.
|
|
172
|
+
* if (!result.ok) {
|
|
173
|
+
* throw result.cause;
|
|
122
174
|
* } else {
|
|
123
175
|
* return result.payment_accepted;
|
|
124
176
|
* }
|
|
125
177
|
* }
|
|
126
178
|
* const paymentAccepted: boolean =
|
|
127
|
-
* await ctx.
|
|
179
|
+
* await ctx.run("paymentAction", paymentAction);
|
|
128
180
|
*
|
|
129
|
-
* @param
|
|
130
|
-
* @param
|
|
181
|
+
* @param action The function to run.
|
|
182
|
+
* @param nameOrOptions the operation's name or a run configuration
|
|
131
183
|
*/
|
|
132
|
-
|
|
184
|
+
run<T>(action: RunAction<T>): Promise<T>;
|
|
185
|
+
/**
|
|
186
|
+
* Run an operation and store the result in Restate. The operation will thus not
|
|
187
|
+
* be re-run during a later replay, but take the durable result from Restate.
|
|
188
|
+
*
|
|
189
|
+
* @param name the action's name
|
|
190
|
+
* @param action the action to run.
|
|
191
|
+
*/
|
|
192
|
+
run<T>(name: string, action: RunAction<T>): Promise<T>;
|
|
133
193
|
/**
|
|
134
194
|
* Register an awakeable and pause the processing until the awakeable ID (and optional payload) have been returned to the service
|
|
135
195
|
* (via ctx.completeAwakeable(...)). The SDK deserializes the payload with `JSON.parse(result.toString()) as T`.
|
|
@@ -138,7 +198,6 @@ export interface Context {
|
|
|
138
198
|
* - promise: the Promise that needs to be awaited and that is resolved with the payload that was supplied by the service which completed the awakeable
|
|
139
199
|
*
|
|
140
200
|
* @example
|
|
141
|
-
* const ctx = restate.useContext(this);
|
|
142
201
|
* const awakeable = ctx.awakeable<string>();
|
|
143
202
|
*
|
|
144
203
|
* // send the awakeable ID to some external service that will wake this one back up
|
|
@@ -155,7 +214,7 @@ export interface Context {
|
|
|
155
214
|
promise: CombineablePromise<T>;
|
|
156
215
|
};
|
|
157
216
|
/**
|
|
158
|
-
* Resolve an awakeable
|
|
217
|
+
* Resolve an awakeable.
|
|
159
218
|
* @param id the string ID of the awakeable.
|
|
160
219
|
* This is supplied by the service that needs to be woken up.
|
|
161
220
|
* @param payload the payload to pass to the service that is woken up.
|
|
@@ -163,19 +222,17 @@ export interface Context {
|
|
|
163
222
|
* and deserializes it in the receiving service with `JSON.parse(result.toString()) as T`.
|
|
164
223
|
*
|
|
165
224
|
* @example
|
|
166
|
-
* const ctx = restate.useContext(this);
|
|
167
225
|
* // The sleeping service should have sent the awakeableIdentifier string to this service.
|
|
168
226
|
* ctx.resolveAwakeable(awakeableIdentifier, "hello");
|
|
169
227
|
*/
|
|
170
228
|
resolveAwakeable<T>(id: string, payload?: T): void;
|
|
171
229
|
/**
|
|
172
|
-
* Reject an awakeable
|
|
230
|
+
* Reject an awakeable. When rejecting, the service waiting on this awakeable will be woken up with a terminal error with the provided reason.
|
|
173
231
|
* @param id the string ID of the awakeable.
|
|
174
232
|
* This is supplied by the service that needs to be woken up.
|
|
175
233
|
* @param reason the reason of the rejection.
|
|
176
234
|
*
|
|
177
235
|
* @example
|
|
178
|
-
* const ctx = restate.useContext(this);
|
|
179
236
|
* // The sleeping service should have sent the awakeableIdentifier string to this service.
|
|
180
237
|
* ctx.rejectAwakeable(awakeableIdentifier, "super bad error");
|
|
181
238
|
*/
|
|
@@ -186,7 +243,6 @@ export interface Context {
|
|
|
186
243
|
* This is a lower-bound.
|
|
187
244
|
*
|
|
188
245
|
* @example
|
|
189
|
-
* const ctx = restate.useContext(this);
|
|
190
246
|
* await ctx.sleep(1000);
|
|
191
247
|
*/
|
|
192
248
|
sleep(millis: number): CombineablePromise<void>;
|
|
@@ -206,29 +262,38 @@ export interface Context {
|
|
|
206
262
|
* @example
|
|
207
263
|
* *Service Side:*
|
|
208
264
|
* ```ts
|
|
209
|
-
* const
|
|
210
|
-
*
|
|
211
|
-
*
|
|
265
|
+
* const service = restate.service(
|
|
266
|
+
* name: "myservice",
|
|
267
|
+
* handlers: {
|
|
268
|
+
* someAction: async(ctx: restate.RpcContext, req: string) => { ... },
|
|
269
|
+
* anotherAction: async(ctx: restate.RpcContext, count: number) => { ... }
|
|
212
270
|
* });
|
|
213
271
|
*
|
|
214
272
|
* // option 1: export only the type signature of the router
|
|
215
|
-
* export type
|
|
273
|
+
* export type MyApi = typeof service;
|
|
216
274
|
*
|
|
217
|
-
* // option 2: export the API definition with type and name (
|
|
218
|
-
*
|
|
275
|
+
* // option 2: export the API definition with type and name (name)
|
|
276
|
+
* const MyService: MyApi = { name: "myservice" };
|
|
219
277
|
*
|
|
220
|
-
* restate.createServer().
|
|
278
|
+
* restate.createServer().bind(service).listen(9080);
|
|
221
279
|
* ```
|
|
222
280
|
* **Client side:**
|
|
223
281
|
* ```ts
|
|
224
282
|
* // option 1: use only types and supply service name separately
|
|
225
|
-
* const result1 = await ctx.
|
|
283
|
+
* const result1 = await ctx.serviceClient<MyApi>({name: "myservice"}).someAction("hello!");
|
|
226
284
|
*
|
|
227
285
|
* // option 2: use full API spec
|
|
228
|
-
* const result2 = await ctx.
|
|
286
|
+
* const result2 = await ctx.serviceClient(MyService).anotherAction(1337);
|
|
229
287
|
* ```
|
|
230
288
|
*/
|
|
231
|
-
|
|
289
|
+
serviceClient<P extends string, M>(opts: ServiceDefinition<P, M>): Client<M>;
|
|
290
|
+
/**
|
|
291
|
+
* Same as {@link serviceClient} but for virtual objects.
|
|
292
|
+
*
|
|
293
|
+
* @param opts
|
|
294
|
+
* @param key the virtual object key
|
|
295
|
+
*/
|
|
296
|
+
objectClient<P extends string, M>(opts: VirtualObjectDefinition<P, M>, key: string): Client<M>;
|
|
232
297
|
/**
|
|
233
298
|
* Makes a type-safe one-way RPC to the specified target service. This method effectively behaves
|
|
234
299
|
* like enqueuing the message in a message queue.
|
|
@@ -246,94 +311,59 @@ export interface Context {
|
|
|
246
311
|
* @example
|
|
247
312
|
* *Service Side:*
|
|
248
313
|
* ```ts
|
|
249
|
-
* const
|
|
250
|
-
*
|
|
251
|
-
*
|
|
314
|
+
* const service = restate.service(
|
|
315
|
+
* name: "myservice",
|
|
316
|
+
* handlers: {
|
|
317
|
+
* someAction: async(ctx: restate.RpcContext, req: string) => { ... },
|
|
318
|
+
* anotherAction: async(ctx: restate.RpcContext, count: number) => { ... }
|
|
252
319
|
* });
|
|
253
320
|
*
|
|
254
321
|
* // option 1: export only the type signature of the router
|
|
255
|
-
* export type
|
|
322
|
+
* export type MyApi = typeof service;
|
|
256
323
|
*
|
|
257
|
-
* // option 2: export the API definition with type and name (
|
|
258
|
-
*
|
|
324
|
+
* // option 2: export the API definition with type and name (name)
|
|
325
|
+
* const MyService: MyApi = { name: "myservice" };
|
|
259
326
|
*
|
|
260
|
-
* restate.createServer().
|
|
327
|
+
* restate.createServer().bind(service).listen(9080);
|
|
261
328
|
* ```
|
|
262
329
|
* **Client side:**
|
|
263
330
|
* ```ts
|
|
264
331
|
* // option 1: use only types and supply service name separately
|
|
265
|
-
* ctx.
|
|
332
|
+
* ctx.serviceSendClient<MyApi>({name: "myservice"}).someAction("hello!");
|
|
266
333
|
*
|
|
267
334
|
* // option 2: use full API spec
|
|
268
|
-
* ctx.
|
|
335
|
+
* ctx.serviceSendClient(MyService).anotherAction(1337);
|
|
269
336
|
* ```
|
|
270
337
|
*/
|
|
271
|
-
|
|
338
|
+
serviceSendClient<P extends string, M>(service: ServiceDefinition<P, M>, opts?: SendOptions): SendClient<M>;
|
|
272
339
|
/**
|
|
273
|
-
*
|
|
274
|
-
* milliseconds' argument.
|
|
275
|
-
* This method is like stetting up a fault-tolerant cron job that enqueues the message in a
|
|
276
|
-
* message queue.
|
|
277
|
-
* The handler calling this function does not have to stay active for the delay time.
|
|
340
|
+
* Same as {@link serviceSendClient} but for virtual objects.
|
|
278
341
|
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* The delay message is journaled for durable execution and will thus not be duplicated when the
|
|
284
|
-
* handler is re-invoked for retries or after suspending.
|
|
285
|
-
*
|
|
286
|
-
* This call will return immediately; the message sending happens asynchronously in the background.
|
|
287
|
-
* Despite that, the message is guaranteed to be sent, because the completion of the invocation that
|
|
288
|
-
* triggers the send (calls this function) happens logically after the sending. That means that any
|
|
289
|
-
* failure where the message does not reach Restate also cannot complete this invocation, and will
|
|
290
|
-
* hence recover this handler and (through the durable execution) recover the message to be sent.
|
|
291
|
-
*
|
|
292
|
-
* @example
|
|
293
|
-
* *Service Side:*
|
|
294
|
-
* ```ts
|
|
295
|
-
* const router = restate.router({
|
|
296
|
-
* someAction: async(ctx: restate.RpcContext, req: string) => { ... },
|
|
297
|
-
* anotherAction: async(ctx: restate.RpcContext, count: number) => { ... }
|
|
298
|
-
* });
|
|
299
|
-
*
|
|
300
|
-
* // option 1: export only the type signature of the router
|
|
301
|
-
* export type myApiType = typeof router;
|
|
302
|
-
*
|
|
303
|
-
* // option 2: export the API definition with type and name (path)
|
|
304
|
-
* export const myApi: restate.ServiceApi<typeof router> = { path : "myservice" };
|
|
305
|
-
*
|
|
306
|
-
* restate.createServer().bindRouter("myservice", router).listen(9080);
|
|
307
|
-
* ```
|
|
308
|
-
* **Client side:**
|
|
309
|
-
* ```ts
|
|
310
|
-
* // option 1: use only types and supply service name separately
|
|
311
|
-
* ctx.sendDelayed<myApiType>({path: "myservice"}, 60_000).someAction("hello!");
|
|
312
|
-
*
|
|
313
|
-
* // option 2: use full API spec
|
|
314
|
-
* ctx.sendDelayed(myApi, 60_000).anotherAction(1337);
|
|
315
|
-
* ```
|
|
342
|
+
* @param obj
|
|
343
|
+
* @param key the virtual object key
|
|
344
|
+
* @param opts Send options
|
|
316
345
|
*/
|
|
317
|
-
|
|
346
|
+
objectSendClient<P extends string, M>(obj: VirtualObjectDefinition<P, M>, key: string, opts?: SendOptions): SendClient<M>;
|
|
318
347
|
/**
|
|
319
|
-
*
|
|
348
|
+
* Returns the raw request that triggered that handler.
|
|
349
|
+
* Use that object to inspect the original request headers
|
|
320
350
|
*/
|
|
321
|
-
|
|
351
|
+
request(): Request;
|
|
322
352
|
}
|
|
323
353
|
/**
|
|
324
354
|
* The context that gives access to all Restate-backed operations, for example
|
|
325
355
|
* - sending reliable messages / RPC through Restate
|
|
326
356
|
* - access/update state
|
|
327
|
-
* -
|
|
357
|
+
* - execute non-deterministic closures and memoize their result
|
|
328
358
|
* - sleeps and delayed calls
|
|
329
359
|
* - awakeables
|
|
330
360
|
* - ...
|
|
331
361
|
*
|
|
332
|
-
* This context can be used only within
|
|
362
|
+
* This context can be used only within virtual objects.
|
|
333
363
|
*
|
|
334
|
-
* In gRPC-based API, to access this context, use {@link useKeyedContext}.
|
|
335
364
|
*/
|
|
336
|
-
export interface
|
|
365
|
+
export interface ObjectContext extends Context, KeyValueStore {
|
|
366
|
+
key: string;
|
|
337
367
|
}
|
|
338
368
|
export interface Rand {
|
|
339
369
|
/**
|
|
@@ -351,7 +381,6 @@ export interface Rand {
|
|
|
351
381
|
* A promise that can be combined using Promise combinators in RestateContext.
|
|
352
382
|
*/
|
|
353
383
|
export type CombineablePromise<T> = Promise<T> & {
|
|
354
|
-
__restate_context: Context;
|
|
355
384
|
/**
|
|
356
385
|
* Creates a promise that awaits for the current promise up to the specified timeout duration.
|
|
357
386
|
* If the timeout is fired, this Promise will be rejected with a {@link TimeoutError}.
|
|
@@ -404,111 +433,4 @@ export declare const CombineablePromise: {
|
|
|
404
433
|
*/
|
|
405
434
|
allSettled<T_3 extends [] | readonly CombineablePromise<unknown>[]>(values: T_3): Promise<{ -readonly [P_1 in keyof T_3]: PromiseSettledResult<Awaited<T_3[P_1]>>; }>;
|
|
406
435
|
};
|
|
407
|
-
/**
|
|
408
|
-
* Interface to interact with **gRPC** based services. You can use this interface to instantiate a gRPC generated client.
|
|
409
|
-
*/
|
|
410
|
-
export interface RestateGrpcChannel {
|
|
411
|
-
/**
|
|
412
|
-
* Unidirectional call to other Restate services ( = in background / async / not waiting on response).
|
|
413
|
-
* To do this, wrap the call via the proto-ts client with oneWayCall, as shown in the example.
|
|
414
|
-
*
|
|
415
|
-
* NOTE: this returns a Promise because we override the gRPC clients provided by proto-ts.
|
|
416
|
-
* So we are required to return a Promise.
|
|
417
|
-
*
|
|
418
|
-
* @param call Invoke another service by using the generated proto-ts client.
|
|
419
|
-
* @example
|
|
420
|
-
* const ctx = restate.useContext(this);
|
|
421
|
-
* const client = new GreeterClientImpl(ctx);
|
|
422
|
-
* await ctx.oneWayCall(() =>
|
|
423
|
-
* client.greet(Request.create({ name: "Peter" }))
|
|
424
|
-
* )
|
|
425
|
-
*/
|
|
426
|
-
oneWayCall(call: () => Promise<any>): Promise<void>;
|
|
427
|
-
/**
|
|
428
|
-
* Delayed unidirectional call to other Restate services ( = in background / async / not waiting on response).
|
|
429
|
-
* To do this, wrap the call via the proto-ts client with delayedCall, as shown in the example.
|
|
430
|
-
* Add the delay in millis as the second parameter.
|
|
431
|
-
*
|
|
432
|
-
* NOTE: this returns a Promise because we override the gRPC clients provided by proto-ts.
|
|
433
|
-
* So we are required to return a Promise.
|
|
434
|
-
*
|
|
435
|
-
* @param call Invoke another service by using the generated proto-ts client.
|
|
436
|
-
* @param delayMillis millisecond delay duration to delay the execution of the call
|
|
437
|
-
* @example
|
|
438
|
-
* const ctx = restate.useContext(this);
|
|
439
|
-
* const client = new GreeterClientImpl(ctx);
|
|
440
|
-
* await ctx.delayedCall(() =>
|
|
441
|
-
* client.greet(Request.create({ name: "Peter" })),
|
|
442
|
-
* 5000
|
|
443
|
-
* )
|
|
444
|
-
*/
|
|
445
|
-
delayedCall(call: () => Promise<any>, delayMillis?: number): Promise<void>;
|
|
446
|
-
/**
|
|
447
|
-
* Call another Restate service and await the response.
|
|
448
|
-
*
|
|
449
|
-
* This function is not recommended to be called directly. Instead, use the generated gRPC client
|
|
450
|
-
* that was generated based on the Protobuf service definitions (which internally use this method):
|
|
451
|
-
*
|
|
452
|
-
* @example
|
|
453
|
-
* ```
|
|
454
|
-
* const ctx = restate.useContext(this);
|
|
455
|
-
* const client = new GreeterClientImpl(ctx);
|
|
456
|
-
* client.greet(Request.create({ name: "Peter" }))
|
|
457
|
-
* ```
|
|
458
|
-
*
|
|
459
|
-
* @param service name of the service to call
|
|
460
|
-
* @param method name of the method to call
|
|
461
|
-
* @param data payload as Uint8Array
|
|
462
|
-
* @returns a Promise that is resolved with the response of the called service
|
|
463
|
-
*/
|
|
464
|
-
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* @deprecated use {@link KeyedContext}.
|
|
468
|
-
*/
|
|
469
|
-
export type RestateContext = KeyedContext;
|
|
470
|
-
/**
|
|
471
|
-
* Returns the {@link Context} which is the entrypoint for all interaction with Restate.
|
|
472
|
-
* Use this from within a method to retrieve the {@link Context}.
|
|
473
|
-
* The context is bounded to a single invocation.
|
|
474
|
-
*
|
|
475
|
-
* @example
|
|
476
|
-
* const ctx = restate.useContext(this);
|
|
477
|
-
*
|
|
478
|
-
*/
|
|
479
|
-
export declare function useContext<T>(instance: T): Context;
|
|
480
|
-
/**
|
|
481
|
-
* Returns the {@link KeyedContext} which is the entrypoint for all interaction with Restate.
|
|
482
|
-
* Use this from within a method of a keyed service to retrieve the {@link KeyedContext}.
|
|
483
|
-
* The context is bounded to a single invocation.
|
|
484
|
-
*
|
|
485
|
-
* @example
|
|
486
|
-
* const ctx = restate.useKeyedContext(this);
|
|
487
|
-
*
|
|
488
|
-
*/
|
|
489
|
-
export declare function useKeyedContext<T>(instance: T): KeyedContext;
|
|
490
|
-
/**
|
|
491
|
-
* ServiceApi captures the type and parameters to make RPC calls and send messages to
|
|
492
|
-
* a set of RPC handlers in a router.
|
|
493
|
-
*
|
|
494
|
-
* @example
|
|
495
|
-
* **Service Side:**
|
|
496
|
-
* ```ts
|
|
497
|
-
* const router = restate.router({
|
|
498
|
-
* someAction: async(ctx: restate.RpcContext, req: string) => { ... },
|
|
499
|
-
* anotherAction: async(ctx: restate.RpcContext, count: number) => { ... }
|
|
500
|
-
* });
|
|
501
|
-
*
|
|
502
|
-
* export const myApi: restate.ServiceApi<typeof router> = { path : "myservice" };
|
|
503
|
-
*
|
|
504
|
-
* restate.createServer().bindRouter("myservice", router).listen(9080);
|
|
505
|
-
* ```
|
|
506
|
-
* **Client side:**
|
|
507
|
-
* ```ts
|
|
508
|
-
* ctx.rpc(myApi).someAction("hello!");
|
|
509
|
-
* ```
|
|
510
|
-
*/
|
|
511
|
-
export type ServiceApi<_M = unknown> = {
|
|
512
|
-
path: string;
|
|
513
|
-
};
|
|
514
436
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"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"}
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
13
|
+
exports.CombineablePromise = void 0;
|
|
14
|
+
const context_impl_1 = require("./context_impl");
|
|
14
15
|
exports.CombineablePromise = {
|
|
15
16
|
/**
|
|
16
17
|
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
|
@@ -25,7 +26,7 @@ exports.CombineablePromise = {
|
|
|
25
26
|
if (values.length == 0) {
|
|
26
27
|
return Promise.all(values);
|
|
27
28
|
}
|
|
28
|
-
return
|
|
29
|
+
return context_impl_1.ContextImpl.createCombinator(Promise.all.bind(Promise), values);
|
|
29
30
|
},
|
|
30
31
|
/**
|
|
31
32
|
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
|
@@ -40,7 +41,7 @@ exports.CombineablePromise = {
|
|
|
40
41
|
if (values.length == 0) {
|
|
41
42
|
return Promise.race(values);
|
|
42
43
|
}
|
|
43
|
-
return
|
|
44
|
+
return context_impl_1.ContextImpl.createCombinator(Promise.race.bind(Promise), values);
|
|
44
45
|
},
|
|
45
46
|
/**
|
|
46
47
|
* Creates a promise that fulfills when any of the input's promises fulfills, with this first fulfillment value.
|
|
@@ -56,7 +57,7 @@ exports.CombineablePromise = {
|
|
|
56
57
|
if (values.length == 0) {
|
|
57
58
|
return Promise.any(values);
|
|
58
59
|
}
|
|
59
|
-
return
|
|
60
|
+
return context_impl_1.ContextImpl.createCombinator(Promise.any.bind(Promise), values);
|
|
60
61
|
},
|
|
61
62
|
/**
|
|
62
63
|
* Creates a promise that fulfills when all the input's promises settle (including when an empty iterable is passed),
|
|
@@ -71,43 +72,7 @@ exports.CombineablePromise = {
|
|
|
71
72
|
if (values.length == 0) {
|
|
72
73
|
return Promise.allSettled(values);
|
|
73
74
|
}
|
|
74
|
-
return
|
|
75
|
+
return context_impl_1.ContextImpl.createCombinator(Promise.allSettled.bind(Promise), values);
|
|
75
76
|
},
|
|
76
77
|
};
|
|
77
|
-
/**
|
|
78
|
-
* Returns the {@link Context} which is the entrypoint for all interaction with Restate.
|
|
79
|
-
* Use this from within a method to retrieve the {@link Context}.
|
|
80
|
-
* The context is bounded to a single invocation.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* const ctx = restate.useContext(this);
|
|
84
|
-
*
|
|
85
|
-
*/
|
|
86
|
-
function useContext(instance) {
|
|
87
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
|
-
const wrapper = instance;
|
|
89
|
-
if (wrapper.$$restate === undefined || wrapper.$$restate === null) {
|
|
90
|
-
throw new Error(`not running within a Restate call.`);
|
|
91
|
-
}
|
|
92
|
-
return wrapper.$$restate;
|
|
93
|
-
}
|
|
94
|
-
exports.useContext = useContext;
|
|
95
|
-
/**
|
|
96
|
-
* Returns the {@link KeyedContext} which is the entrypoint for all interaction with Restate.
|
|
97
|
-
* Use this from within a method of a keyed service to retrieve the {@link KeyedContext}.
|
|
98
|
-
* The context is bounded to a single invocation.
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* const ctx = restate.useKeyedContext(this);
|
|
102
|
-
*
|
|
103
|
-
*/
|
|
104
|
-
function useKeyedContext(instance) {
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
|
-
const wrapper = instance;
|
|
107
|
-
if (wrapper.$$restate === undefined || wrapper.$$restate === null) {
|
|
108
|
-
throw new Error(`not running within a Restate call.`);
|
|
109
|
-
}
|
|
110
|
-
return wrapper.$$restate;
|
|
111
|
-
}
|
|
112
|
-
exports.useKeyedContext = useKeyedContext;
|
|
113
78
|
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAQH,iDAA6C;AA2ahC,QAAA,kBAAkB,GAAG;IAChC;;;;;;;;OAQG;IACH,GAAG,CACD,MAAS;QAET,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;YACtB,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SAC5B;QACD,OAAO,0BAAW,CAAC,gBAAgB,CACjC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,EACzB,MAAM,CAGN,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACH,IAAI,CACF,MAAS;QAET,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;YACtB,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC7B;QACD,OAAO,0BAAW,CAAC,gBAAgB,CACjC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAC1B,MAAM,CACwB,CAAC;IACnC,CAAC;IAED;;;;;;;;;OASG;IACH,GAAG,CACD,MAAS;QAET,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;YACtB,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SAC5B;QACD,OAAO,0BAAW,CAAC,gBAAgB,CACjC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,EACzB,MAAM,CACwB,CAAC;IACnC,CAAC;IAED;;;;;;;;OAQG;IACH,UAAU,CACR,MAAS;QAIT,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;YACtB,OAAO,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;SACnC;QACD,OAAO,0BAAW,CAAC,gBAAgB,CACjC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAChC,MAAM,CAGN,CAAC;IACL,CAAC;CACF,CAAC"}
|