effect 4.0.0-beta.31 → 4.0.0-beta.33
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/Array.d.ts +87 -86
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +47 -40
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +46 -45
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +35 -38
- package/dist/BigDecimal.js.map +1 -1
- package/dist/BigInt.d.ts +39 -32
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +32 -29
- package/dist/BigInt.js.map +1 -1
- package/dist/Chunk.d.ts +58 -57
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +20 -21
- package/dist/Chunk.js.map +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +4 -1
- package/dist/Config.js.map +1 -1
- package/dist/Cron.d.ts +3 -6
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +8 -15
- package/dist/Cron.js.map +1 -1
- package/dist/DateTime.d.ts +16 -15
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +8 -8
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +7 -5
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +7 -5
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +26 -24
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +23 -22
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +7 -3
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +3 -4
- package/dist/Effect.js.map +1 -1
- package/dist/Fiber.d.ts +2 -1
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +9 -8
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +8 -7
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +20 -19
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +6 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +17 -16
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +10 -7
- package/dist/FileSystem.js.map +1 -1
- package/dist/Graph.d.ts +64 -64
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +53 -53
- package/dist/Graph.js.map +1 -1
- package/dist/HashMap.d.ts +11 -5
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +3 -1
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +11 -11
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +12 -12
- package/dist/Iterable.js.map +1 -1
- package/dist/Latch.d.ts +69 -3
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Latch.js +58 -0
- package/dist/Latch.js.map +1 -1
- package/dist/Layer.d.ts +84 -0
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +27 -0
- package/dist/Layer.js.map +1 -1
- package/dist/Number.d.ts +74 -18
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +34 -15
- package/dist/Number.js.map +1 -1
- package/dist/Option.d.ts +2 -0
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +183 -0
- package/dist/PartitionedSemaphore.d.ts.map +1 -0
- package/dist/PartitionedSemaphore.js +231 -0
- package/dist/PartitionedSemaphore.js.map +1 -0
- package/dist/PubSub.d.ts +5 -4
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +6 -5
- package/dist/PubSub.js.map +1 -1
- package/dist/Queue.d.ts +4 -4
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +2 -2
- package/dist/Queue.js.map +1 -1
- package/dist/Record.d.ts +40 -40
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +16 -15
- package/dist/Record.js.map +1 -1
- package/dist/Scheduler.d.ts +25 -123
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +20 -123
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +30 -0
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +28 -1
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaGetter.js +6 -4
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +32 -27
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Semaphore.d.ts +149 -53
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +137 -117
- package/dist/Semaphore.js.map +1 -1
- package/dist/ServiceMap.d.ts +26 -0
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +36 -21
- package/dist/ServiceMap.js.map +1 -1
- package/dist/Stream.js +1 -1
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +114 -47
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +29 -47
- package/dist/String.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +1 -2
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +81 -115
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/Terminal.d.ts +2 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +5 -4
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +2 -1
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +26 -14
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +8 -4
- package/dist/Trie.js.map +1 -1
- package/dist/TxHashMap.d.ts +77 -59
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +25 -19
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxSemaphore.d.ts +162 -2
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +16 -2
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/index.d.ts +88 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +88 -32
- package/dist/index.js.map +1 -1
- package/dist/internal/dateTime.js +9 -9
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +20 -89
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +2 -1
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/option.js +6 -0
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/trie.js +3 -3
- package/dist/internal/trie.js.map +1 -1
- package/dist/unstable/ai/AiError.js +1 -1
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +2 -2
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +8 -0
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +112 -11
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/ResponseIdTracker.d.ts +38 -0
- package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
- package/dist/unstable/ai/ResponseIdTracker.js +68 -0
- package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
- package/dist/unstable/ai/Tool.d.ts +14 -0
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +13 -0
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +4 -0
- package/dist/unstable/ai/index.d.ts.map +1 -1
- package/dist/unstable/ai/index.js +4 -0
- package/dist/unstable/ai/index.js.map +1 -1
- package/dist/unstable/cli/Argument.d.ts +2 -4
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +1 -3
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliOutput.d.ts +3 -2
- package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
- package/dist/unstable/cli/CliOutput.js +4 -3
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +3 -2
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +3 -3
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +2 -2
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/HelpDoc.d.ts +14 -12
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +4 -4
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +7 -7
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +1 -1
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +71 -67
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js +9 -2
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +8 -3
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +25 -23
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +3 -2
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +7 -7
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +4 -3
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +3 -2
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +12 -12
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +2 -1
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +4 -3
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +9 -8
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +2 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +7 -6
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +19 -13
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +5 -4
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +4 -4
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +9 -10
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +2 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +1 -4
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +5 -4
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +3 -4
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts.map +1 -1
- package/dist/unstable/http/Etag.js +5 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +3 -2
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +2 -1
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +2 -1
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +4 -3
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +8 -6
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +2 -1
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +2 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +16 -15
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +3 -2
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +2 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +7 -7
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +2 -2
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +2 -1
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +2 -1
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +3 -2
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +14 -10
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +4 -3
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
- package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js +27 -15
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +5 -4
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +5 -6
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +4 -2
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +15 -0
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +81 -3
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +2 -2
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +7 -3
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +1 -5
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +4 -2
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -3
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +4 -4
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +3 -2
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +4 -1
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +3 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +2 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +5 -3
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +1 -1
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +6 -6
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +2 -1
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +5 -4
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +19 -14
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +112 -105
- package/src/BigDecimal.ts +63 -66
- package/src/BigInt.ts +49 -41
- package/src/Chunk.ts +68 -63
- package/src/Config.ts +4 -1
- package/src/Cron.ts +10 -15
- package/src/DateTime.ts +16 -15
- package/src/Deferred.ts +8 -6
- package/src/Duration.ts +34 -33
- package/src/Effect.ts +12 -23
- package/src/Fiber.ts +2 -1
- package/src/FiberHandle.ts +10 -9
- package/src/FiberMap.ts +22 -22
- package/src/FileSystem.ts +25 -22
- package/src/Graph.ts +105 -105
- package/src/HashMap.ts +11 -5
- package/src/Iterable.ts +13 -13
- package/src/Latch.ts +85 -3
- package/src/Layer.ts +121 -0
- package/src/Number.ts +85 -26
- package/src/Option.ts +2 -0
- package/src/PartitionedSemaphore.ts +414 -0
- package/src/PubSub.ts +7 -6
- package/src/Queue.ts +6 -6
- package/src/Record.ts +52 -47
- package/src/Scheduler.ts +37 -126
- package/src/Schema.ts +49 -1
- package/src/SchemaGetter.ts +4 -4
- package/src/SchemaTransformation.ts +27 -27
- package/src/Semaphore.ts +271 -183
- package/src/ServiceMap.ts +83 -31
- package/src/Stream.ts +1 -1
- package/src/String.ts +122 -69
- package/src/SubscriptionRef.ts +96 -117
- package/src/Terminal.ts +2 -1
- package/src/Tracer.ts +6 -5
- package/src/Trie.ts +26 -14
- package/src/TxHashMap.ts +78 -60
- package/src/TxSemaphore.ts +186 -11
- package/src/index.ts +89 -33
- package/src/internal/dateTime.ts +14 -14
- package/src/internal/effect.ts +29 -121
- package/src/internal/hashMap.ts +4 -3
- package/src/internal/option.ts +7 -0
- package/src/internal/trie.ts +6 -6
- package/src/unstable/ai/AiError.ts +1 -1
- package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
- package/src/unstable/ai/Chat.ts +6 -2
- package/src/unstable/ai/LanguageModel.ts +192 -65
- package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
- package/src/unstable/ai/ResponseIdTracker.ts +97 -0
- package/src/unstable/ai/Tool.ts +20 -0
- package/src/unstable/ai/index.ts +5 -0
- package/src/unstable/cli/Argument.ts +2 -4
- package/src/unstable/cli/CliOutput.ts +7 -5
- package/src/unstable/cli/Command.ts +5 -5
- package/src/unstable/cli/Flag.ts +2 -2
- package/src/unstable/cli/HelpDoc.ts +14 -12
- package/src/unstable/cli/Param.ts +15 -11
- package/src/unstable/cli/Primitive.ts +1 -1
- package/src/unstable/cli/Prompt.ts +81 -83
- package/src/unstable/cli/internal/completions/CommandDescriptor.ts +3 -2
- package/src/unstable/cli/internal/parser.ts +7 -4
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +35 -30
- package/src/unstable/cluster/Entity.ts +13 -12
- package/src/unstable/cluster/Message.ts +6 -5
- package/src/unstable/cluster/MessageStorage.ts +26 -25
- package/src/unstable/cluster/Reply.ts +7 -4
- package/src/unstable/cluster/RunnerServer.ts +10 -13
- package/src/unstable/cluster/Runners.ts +8 -7
- package/src/unstable/cluster/Sharding.ts +24 -17
- package/src/unstable/cluster/ShardingConfig.ts +6 -6
- package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
- package/src/unstable/cluster/internal/entityManager.ts +27 -21
- package/src/unstable/devtools/DevToolsSchema.ts +3 -2
- package/src/unstable/http/Cookies.ts +7 -8
- package/src/unstable/http/Etag.ts +5 -3
- package/src/unstable/http/Headers.ts +6 -5
- package/src/unstable/http/HttpClient.ts +2 -1
- package/src/unstable/http/HttpClientRequest.ts +11 -9
- package/src/unstable/http/HttpClientResponse.ts +3 -2
- package/src/unstable/http/HttpIncomingMessage.ts +2 -1
- package/src/unstable/http/HttpMiddleware.ts +16 -15
- package/src/unstable/http/HttpPlatform.ts +3 -2
- package/src/unstable/http/HttpRouter.ts +9 -9
- package/src/unstable/http/HttpServer.ts +3 -9
- package/src/unstable/http/HttpServerError.ts +3 -2
- package/src/unstable/http/HttpServerRequest.ts +25 -21
- package/src/unstable/http/HttpServerResponse.ts +5 -4
- package/src/unstable/http/HttpTraceContext.ts +31 -17
- package/src/unstable/http/UrlParams.ts +11 -14
- package/src/unstable/httpapi/HttpApiBuilder.ts +9 -3
- package/src/unstable/httpapi/HttpApiError.ts +67 -12
- package/src/unstable/observability/OtlpExporter.ts +5 -2
- package/src/unstable/observability/OtlpTracer.ts +8 -4
- package/src/unstable/reactivity/Atom.ts +1 -4
- package/src/unstable/reactivity/AtomRegistry.ts +5 -3
- package/src/unstable/rpc/Rpc.ts +4 -3
- package/src/unstable/rpc/RpcClient.ts +10 -9
- package/src/unstable/rpc/RpcSchema.ts +6 -5
- package/src/unstable/rpc/RpcSerialization.ts +4 -1
- package/src/unstable/rpc/RpcServer.ts +3 -3
- package/src/unstable/socket/Socket.ts +14 -9
- package/src/unstable/sql/SqlClient.ts +5 -3
- package/src/unstable/workflow/DurableDeferred.ts +6 -6
- package/src/unstable/workflow/Workflow.ts +1 -1
- package/src/unstable/workflow/WorkflowEngine.ts +29 -20
- package/dist/NullOr.d.ts +0 -149
- package/dist/NullOr.d.ts.map +0 -1
- package/dist/NullOr.js +0 -152
- package/dist/NullOr.js.map +0 -1
- package/src/NullOr.ts +0 -204
|
@@ -8,6 +8,7 @@ import * as Exit from "../../Exit.ts"
|
|
|
8
8
|
import * as Fiber from "../../Fiber.ts"
|
|
9
9
|
import * as Latch from "../../Latch.ts"
|
|
10
10
|
import * as Layer from "../../Layer.ts"
|
|
11
|
+
import * as Option from "../../Option.ts"
|
|
11
12
|
import * as PrimaryKey from "../../PrimaryKey.ts"
|
|
12
13
|
import * as RcMap from "../../RcMap.ts"
|
|
13
14
|
import type * as Record from "../../Record.ts"
|
|
@@ -150,8 +151,9 @@ export const make = Effect.gen(function*() {
|
|
|
150
151
|
const replies = yield* storage.repliesForUnfiltered([requestId])
|
|
151
152
|
const last = replies[replies.length - 1]
|
|
152
153
|
if (last && last._tag === "WithExit") {
|
|
153
|
-
return last as WithExitEncoded<Workflow.ResultEncoded<any, any>>
|
|
154
|
+
return Option.some(last as WithExitEncoded<Workflow.ResultEncoded<any, any>>)
|
|
154
155
|
}
|
|
156
|
+
return Option.none<WithExitEncoded<Workflow.ResultEncoded<any, any>>>()
|
|
155
157
|
})
|
|
156
158
|
|
|
157
159
|
const requestReply = Effect.fnUntraced(function*(options: {
|
|
@@ -162,10 +164,10 @@ export const make = Effect.gen(function*() {
|
|
|
162
164
|
readonly id: string
|
|
163
165
|
}) {
|
|
164
166
|
const requestId = yield* requestIdFor(options)
|
|
165
|
-
if (requestId
|
|
166
|
-
return
|
|
167
|
+
if (Option.isNone(requestId)) {
|
|
168
|
+
return Option.none<WithExitEncoded<Workflow.ResultEncoded<any, any>>>()
|
|
167
169
|
}
|
|
168
|
-
return yield* replyForRequestId(requestId)
|
|
170
|
+
return yield* replyForRequestId(requestId.value)
|
|
169
171
|
})
|
|
170
172
|
|
|
171
173
|
const resetActivityAttempt = Effect.fnUntraced(
|
|
@@ -182,8 +184,8 @@ export const make = Effect.gen(function*() {
|
|
|
182
184
|
tag: "activity",
|
|
183
185
|
id: activityPrimaryKey(options.activity.name, options.attempt)
|
|
184
186
|
})
|
|
185
|
-
if (requestId
|
|
186
|
-
yield* sharding.reset(requestId)
|
|
187
|
+
if (Option.isNone(requestId)) return
|
|
188
|
+
yield* sharding.reset(requestId.value)
|
|
187
189
|
},
|
|
188
190
|
Effect.retry({
|
|
189
191
|
times: 3,
|
|
@@ -218,13 +220,13 @@ export const make = Effect.gen(function*() {
|
|
|
218
220
|
id: ""
|
|
219
221
|
})
|
|
220
222
|
|
|
221
|
-
const maybeSuspended =
|
|
222
|
-
maybeReply
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
const maybeSuspended = Option.filter(
|
|
224
|
+
maybeReply,
|
|
225
|
+
(reply) => reply.exit._tag === "Success" && reply.exit.value._tag === "Suspended"
|
|
226
|
+
)
|
|
225
227
|
|
|
226
|
-
if (maybeSuspended
|
|
227
|
-
yield* sharding.reset(Snowflake.Snowflake(maybeSuspended.requestId))
|
|
228
|
+
if (Option.isNone(maybeSuspended)) return
|
|
229
|
+
yield* sharding.reset(Snowflake.Snowflake(maybeSuspended.value.requestId))
|
|
228
230
|
yield* sharding.pollStorage
|
|
229
231
|
})
|
|
230
232
|
|
|
@@ -239,13 +241,13 @@ export const make = Effect.gen(function*() {
|
|
|
239
241
|
tag: "resume",
|
|
240
242
|
id: ""
|
|
241
243
|
})
|
|
242
|
-
if (requestId
|
|
244
|
+
if (Option.isNone(requestId)) {
|
|
243
245
|
const client = (yield* RcMap.get(clientsPartial, options.workflowName))(options.executionId)
|
|
244
246
|
return yield* client.resume({} as any, { discard: true })
|
|
245
247
|
}
|
|
246
|
-
const reply = yield* replyForRequestId(requestId)
|
|
247
|
-
if (reply
|
|
248
|
-
yield* sharding.reset(requestId)
|
|
248
|
+
const reply = yield* replyForRequestId(requestId.value)
|
|
249
|
+
if (Option.isNone(reply)) return
|
|
250
|
+
yield* sharding.reset(requestId.value)
|
|
249
251
|
}, Effect.scoped)
|
|
250
252
|
|
|
251
253
|
const engine = WorkflowEngine.makeUnsafe({
|
|
@@ -272,7 +274,7 @@ export const make = Effect.gen(function*() {
|
|
|
272
274
|
}
|
|
273
275
|
return engine.deferredResult(InterruptSignal).pipe(
|
|
274
276
|
Effect.flatMap((maybeExit) => {
|
|
275
|
-
if (maybeExit
|
|
277
|
+
if (Option.isNone(maybeExit)) {
|
|
276
278
|
return Effect.void
|
|
277
279
|
}
|
|
278
280
|
instance.suspended = false
|
|
@@ -373,12 +375,12 @@ export const make = Effect.gen(function*() {
|
|
|
373
375
|
tag: "run",
|
|
374
376
|
id: ""
|
|
375
377
|
})
|
|
376
|
-
if (
|
|
377
|
-
const exit = yield* (Schema.decodeUnknownEffect(exitSchema)(reply.exit) as Effect.Effect<
|
|
378
|
+
if (Option.isNone(reply)) return Option.none()
|
|
379
|
+
const exit = yield* (Schema.decodeUnknownEffect(exitSchema)(reply.value.exit) as Effect.Effect<
|
|
378
380
|
Exit.Exit<any, any>,
|
|
379
381
|
Schema.SchemaError
|
|
380
382
|
>)
|
|
381
|
-
return yield* exit
|
|
383
|
+
return Option.some(yield* exit)
|
|
382
384
|
}, Effect.orDie),
|
|
383
385
|
|
|
384
386
|
interrupt: Effect.fnUntraced(
|
|
@@ -392,10 +394,11 @@ export const make = Effect.gen(function*() {
|
|
|
392
394
|
id: ""
|
|
393
395
|
})
|
|
394
396
|
|
|
395
|
-
const nonSuspendedReply =
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
397
|
+
const nonSuspendedReply = Option.filter(
|
|
398
|
+
reply,
|
|
399
|
+
(reply) => reply.exit._tag !== "Success" || reply.exit.value._tag !== "Suspended"
|
|
400
|
+
)
|
|
401
|
+
if (Option.isSome(nonSuspendedReply)) {
|
|
399
402
|
return
|
|
400
403
|
}
|
|
401
404
|
|
|
@@ -463,13 +466,15 @@ export const make = Effect.gen(function*() {
|
|
|
463
466
|
})
|
|
464
467
|
),
|
|
465
468
|
Effect.map((reply) => {
|
|
466
|
-
if (reply
|
|
467
|
-
return
|
|
469
|
+
if (Option.isNone(reply)) {
|
|
470
|
+
return Option.none<Exit.Exit<unknown, unknown>>()
|
|
468
471
|
}
|
|
469
|
-
const decoded = decodeDeferredWithExit(reply as any)
|
|
470
|
-
return
|
|
471
|
-
|
|
472
|
-
|
|
472
|
+
const decoded = decodeDeferredWithExit(reply.value as any)
|
|
473
|
+
return Option.some(
|
|
474
|
+
decoded.exit._tag === "Success"
|
|
475
|
+
? decoded.exit.value
|
|
476
|
+
: decoded.exit
|
|
477
|
+
)
|
|
473
478
|
}),
|
|
474
479
|
Effect.retry({
|
|
475
480
|
while: (e) => e._tag === "PersistenceError",
|
|
@@ -12,13 +12,13 @@ import { identity } from "../../Function.ts"
|
|
|
12
12
|
import * as Hash from "../../Hash.ts"
|
|
13
13
|
import type * as Latch from "../../Latch.ts"
|
|
14
14
|
import * as Layer from "../../Layer.ts"
|
|
15
|
+
import * as Option from "../../Option.ts"
|
|
15
16
|
import * as Predicate from "../../Predicate.ts"
|
|
16
17
|
import * as Queue from "../../Queue.ts"
|
|
17
18
|
import type * as Schedule from "../../Schedule.ts"
|
|
18
19
|
import { Scope } from "../../Scope.ts"
|
|
19
20
|
import * as ServiceMap from "../../ServiceMap.ts"
|
|
20
21
|
import type * as Stream from "../../Stream.ts"
|
|
21
|
-
import * as UndefinedOr from "../../UndefinedOr.ts"
|
|
22
22
|
import * as Headers from "../http/Headers.ts"
|
|
23
23
|
import * as Rpc from "../rpc/Rpc.ts"
|
|
24
24
|
import * as RpcClient from "../rpc/RpcClient.ts"
|
|
@@ -459,24 +459,24 @@ export declare namespace Replier {
|
|
|
459
459
|
*/
|
|
460
460
|
export class Request<Rpc extends Rpc.Any> extends Data.Class<
|
|
461
461
|
Envelope.Request<Rpc> & {
|
|
462
|
-
readonly lastSentChunk: Reply.Chunk<Rpc
|
|
462
|
+
readonly lastSentChunk: Option.Option<Reply.Chunk<Rpc>>
|
|
463
463
|
}
|
|
464
464
|
> {
|
|
465
465
|
/**
|
|
466
466
|
* @since 4.0.0
|
|
467
467
|
*/
|
|
468
|
-
get lastSentChunkValue(): Rpc.SuccessChunk<Rpc
|
|
469
|
-
return
|
|
468
|
+
get lastSentChunkValue(): Option.Option<Rpc.SuccessChunk<Rpc>> {
|
|
469
|
+
return Option.map(this.lastSentChunk, (chunk) => Arr.lastNonEmpty(chunk.values))
|
|
470
470
|
}
|
|
471
471
|
|
|
472
472
|
/**
|
|
473
473
|
* @since 4.0.0
|
|
474
474
|
*/
|
|
475
475
|
get nextSequence(): number {
|
|
476
|
-
if (this.lastSentChunk
|
|
476
|
+
if (Option.isNone(this.lastSentChunk)) {
|
|
477
477
|
return 0
|
|
478
478
|
}
|
|
479
|
-
return this.lastSentChunk.sequence + 1
|
|
479
|
+
return this.lastSentChunk.value.sequence + 1
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
482
|
|
|
@@ -524,10 +524,11 @@ export const makeTestClient: <Type extends string, Rpcs extends Rpc.Any, LA, LE,
|
|
|
524
524
|
services: services as any,
|
|
525
525
|
concurrency: options?.concurrency ?? 1,
|
|
526
526
|
build: entity.protocol.toHandlers(handlers as any).pipe(
|
|
527
|
-
Effect.provideServices(
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
527
|
+
Effect.provideServices(ServiceMap.mutate(services, (services) =>
|
|
528
|
+
services.pipe(
|
|
529
|
+
ServiceMap.add(CurrentRunnerAddress, runnerAddress),
|
|
530
|
+
ServiceMap.omit(Scope)
|
|
531
|
+
)))
|
|
531
532
|
) as any
|
|
532
533
|
})
|
|
533
534
|
return Effect.void
|
|
@@ -570,7 +571,7 @@ export const makeTestClient: <Type extends string, Rpcs extends Rpc.Any, LA, LE,
|
|
|
570
571
|
[Envelope.TypeId]: Envelope.TypeId,
|
|
571
572
|
address,
|
|
572
573
|
requestId: Snowflake.Snowflake(message.id),
|
|
573
|
-
lastSentChunk:
|
|
574
|
+
lastSentChunk: Option.none()
|
|
574
575
|
}) as any
|
|
575
576
|
})
|
|
576
577
|
}
|
|
@@ -619,7 +620,7 @@ export const keepAlive: (
|
|
|
619
620
|
spanId: span.spanId,
|
|
620
621
|
sampled: span.sampled
|
|
621
622
|
}),
|
|
622
|
-
lastReceivedReply:
|
|
623
|
+
lastReceivedReply: Option.none(),
|
|
623
624
|
respond: () => Effect.void
|
|
624
625
|
}),
|
|
625
626
|
true
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as Data from "../../Data.ts"
|
|
5
5
|
import * as Effect from "../../Effect.ts"
|
|
6
|
+
import * as Option from "../../Option.ts"
|
|
6
7
|
import * as Schema from "../../Schema.ts"
|
|
7
8
|
import type { ServiceMap } from "../../ServiceMap.ts"
|
|
8
9
|
import * as Rpc from "../rpc/Rpc.ts"
|
|
@@ -36,7 +37,7 @@ export const incomingLocalFromOutgoing = <R extends Rpc.Any>(self: Outgoing<R>):
|
|
|
36
37
|
return new IncomingRequestLocal({
|
|
37
38
|
envelope: self.envelope,
|
|
38
39
|
respond: self.respond,
|
|
39
|
-
lastSentReply:
|
|
40
|
+
lastSentReply: Option.none()
|
|
40
41
|
})
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -46,7 +47,7 @@ export const incomingLocalFromOutgoing = <R extends Rpc.Any>(self: Outgoing<R>):
|
|
|
46
47
|
*/
|
|
47
48
|
export class IncomingRequest<R extends Rpc.Any> extends Data.TaggedClass("IncomingRequest")<{
|
|
48
49
|
readonly envelope: Envelope.PartialRequest
|
|
49
|
-
readonly lastSentReply: Reply.Encoded
|
|
50
|
+
readonly lastSentReply: Option.Option<Reply.Encoded>
|
|
50
51
|
readonly respond: (reply: Reply.ReplyWithContext<R>) => Effect.Effect<void, MalformedMessage | PersistenceError>
|
|
51
52
|
}> {}
|
|
52
53
|
|
|
@@ -56,7 +57,7 @@ export class IncomingRequest<R extends Rpc.Any> extends Data.TaggedClass("Incomi
|
|
|
56
57
|
*/
|
|
57
58
|
export class IncomingRequestLocal<R extends Rpc.Any> extends Data.TaggedClass("IncomingRequestLocal")<{
|
|
58
59
|
readonly envelope: Envelope.Request<R>
|
|
59
|
-
readonly lastSentReply: Reply.Reply<R
|
|
60
|
+
readonly lastSentReply: Option.Option<Reply.Reply<R>>
|
|
60
61
|
readonly respond: (reply: Reply.Reply<R>) => Effect.Effect<void, MalformedMessage | PersistenceError>
|
|
61
62
|
}> {}
|
|
62
63
|
|
|
@@ -82,7 +83,7 @@ export type Outgoing<R extends Rpc.Any> = OutgoingRequest<R> | OutgoingEnvelope
|
|
|
82
83
|
export class OutgoingRequest<R extends Rpc.Any> extends Data.TaggedClass("OutgoingRequest")<{
|
|
83
84
|
readonly envelope: Envelope.Request<R>
|
|
84
85
|
readonly services: ServiceMap<Rpc.Services<R>>
|
|
85
|
-
readonly lastReceivedReply: Reply.Reply<R
|
|
86
|
+
readonly lastReceivedReply: Option.Option<Reply.Reply<R>>
|
|
86
87
|
readonly rpc: R
|
|
87
88
|
readonly respond: (reply: Reply.Reply<R>) => Effect.Effect<void>
|
|
88
89
|
}> {
|
|
@@ -196,7 +197,7 @@ export const deserializeLocal = <Rpc extends Rpc.Any>(
|
|
|
196
197
|
...encoded,
|
|
197
198
|
payload
|
|
198
199
|
} as any),
|
|
199
|
-
lastSentReply:
|
|
200
|
+
lastSentReply: Option.none(),
|
|
200
201
|
respond: self.respond
|
|
201
202
|
})
|
|
202
203
|
)
|
|
@@ -8,11 +8,10 @@ import * as Effect from "../../Effect.ts"
|
|
|
8
8
|
import * as Exit from "../../Exit.ts"
|
|
9
9
|
import * as Latch from "../../Latch.ts"
|
|
10
10
|
import * as Layer from "../../Layer.ts"
|
|
11
|
-
import
|
|
11
|
+
import * as Option from "../../Option.ts"
|
|
12
12
|
import type { Predicate } from "../../Predicate.ts"
|
|
13
13
|
import * as Schema from "../../Schema.ts"
|
|
14
14
|
import * as ServiceMap from "../../ServiceMap.ts"
|
|
15
|
-
import * as UndefinedOr from "../../UndefinedOr.ts"
|
|
16
15
|
import type * as Rpc from "../rpc/Rpc.ts"
|
|
17
16
|
import { EntityNotAssignedToRunner, MalformedMessage, type PersistenceError } from "./ClusterError.ts"
|
|
18
17
|
import * as DeliverAt from "./DeliverAt.ts"
|
|
@@ -81,7 +80,7 @@ export class MessageStorage extends ServiceMap.Service<MessageStorage, {
|
|
|
81
80
|
readonly tag: string
|
|
82
81
|
readonly id: string
|
|
83
82
|
}
|
|
84
|
-
) => Effect.Effect<Snowflake.Snowflake
|
|
83
|
+
) => Effect.Effect<Option.Option<Snowflake.Snowflake>, PersistenceError>
|
|
85
84
|
|
|
86
85
|
/**
|
|
87
86
|
* For locally sent messages, register a handler to process the replies.
|
|
@@ -187,7 +186,7 @@ export declare namespace SaveResult {
|
|
|
187
186
|
export interface Duplicate<R extends Rpc.Any> {
|
|
188
187
|
readonly _tag: "Duplicate"
|
|
189
188
|
readonly originalId: Snowflake.Snowflake
|
|
190
|
-
readonly lastReceivedReply: Reply.Reply<R
|
|
189
|
+
readonly lastReceivedReply: Option.Option<Reply.Reply<R>>
|
|
191
190
|
}
|
|
192
191
|
|
|
193
192
|
/**
|
|
@@ -197,7 +196,7 @@ export declare namespace SaveResult {
|
|
|
197
196
|
export interface DuplicateEncoded {
|
|
198
197
|
readonly _tag: "Duplicate"
|
|
199
198
|
readonly originalId: Snowflake.Snowflake
|
|
200
|
-
readonly lastReceivedReply: Reply.Encoded
|
|
199
|
+
readonly lastReceivedReply: Option.Option<Reply.Encoded>
|
|
201
200
|
}
|
|
202
201
|
|
|
203
202
|
/**
|
|
@@ -240,7 +239,7 @@ export type Encoded = {
|
|
|
240
239
|
*/
|
|
241
240
|
readonly requestIdForPrimaryKey: (
|
|
242
241
|
primaryKey: string
|
|
243
|
-
) => Effect.Effect<Snowflake.Snowflake
|
|
242
|
+
) => Effect.Effect<Option.Option<Snowflake.Snowflake>, PersistenceError>
|
|
244
243
|
|
|
245
244
|
/**
|
|
246
245
|
* Retrieves the replies for the specified requests.
|
|
@@ -277,7 +276,7 @@ export type Encoded = {
|
|
|
277
276
|
) => Effect.Effect<
|
|
278
277
|
Array<{
|
|
279
278
|
readonly envelope: Envelope.Encoded
|
|
280
|
-
readonly lastSentReply: Reply.Encoded
|
|
279
|
+
readonly lastSentReply: Option.Option<Reply.Encoded>
|
|
281
280
|
}>,
|
|
282
281
|
PersistenceError
|
|
283
282
|
>
|
|
@@ -291,7 +290,7 @@ export type Encoded = {
|
|
|
291
290
|
) => Effect.Effect<
|
|
292
291
|
Array<{
|
|
293
292
|
readonly envelope: Envelope.Encoded
|
|
294
|
-
readonly lastSentReply: Reply.Encoded
|
|
293
|
+
readonly lastSentReply: Option.Option<Reply.Encoded>
|
|
295
294
|
}>,
|
|
296
295
|
PersistenceError
|
|
297
296
|
>
|
|
@@ -463,18 +462,18 @@ export const makeEncoded: (encoded: Encoded) => Effect.Effect<
|
|
|
463
462
|
})
|
|
464
463
|
),
|
|
465
464
|
Effect.flatMap((result) => {
|
|
466
|
-
if (result._tag === "Success" || result.lastReceivedReply
|
|
465
|
+
if (result._tag === "Success" || Option.isNone(result.lastReceivedReply)) {
|
|
467
466
|
return Effect.succeed(result as SaveResult<any>)
|
|
468
467
|
}
|
|
469
468
|
const duplicate = result
|
|
470
469
|
const schema = Reply.Reply(message.rpc)
|
|
471
|
-
return Schema.decodeEffect(schema)(result.lastReceivedReply).pipe(
|
|
470
|
+
return Schema.decodeEffect(schema)(result.lastReceivedReply.value).pipe(
|
|
472
471
|
Effect.provideServices(message.services),
|
|
473
472
|
MalformedMessage.refail,
|
|
474
473
|
Effect.map((reply) =>
|
|
475
474
|
SaveResult.Duplicate({
|
|
476
475
|
originalId: duplicate.originalId,
|
|
477
|
-
lastReceivedReply: reply
|
|
476
|
+
lastReceivedReply: Option.some(reply)
|
|
478
477
|
})
|
|
479
478
|
)
|
|
480
479
|
)
|
|
@@ -546,7 +545,7 @@ export const makeEncoded: (encoded: Encoded) => Effect.Effect<
|
|
|
546
545
|
const decodeMessages = (
|
|
547
546
|
envelopes: Array<{
|
|
548
547
|
readonly envelope: Envelope.Encoded
|
|
549
|
-
readonly lastSentReply: Reply.Encoded
|
|
548
|
+
readonly lastSentReply: Option.Option<Reply.Encoded>
|
|
550
549
|
}>
|
|
551
550
|
) => {
|
|
552
551
|
const messages: Array<Message.Incoming<any>> = []
|
|
@@ -655,7 +654,7 @@ export const noop: MessageStorage["Service"] = Effect.runSync(make({
|
|
|
655
654
|
clearReplies: () => Effect.void,
|
|
656
655
|
repliesFor: () => Effect.succeed([]),
|
|
657
656
|
repliesForUnfiltered: () => Effect.succeed([]),
|
|
658
|
-
requestIdForPrimaryKey: () => Effect.
|
|
657
|
+
requestIdForPrimaryKey: () => Effect.succeedNone,
|
|
659
658
|
unprocessedMessages: () => Effect.succeed([]),
|
|
660
659
|
unprocessedMessagesById: () => Effect.succeed([]),
|
|
661
660
|
resetAddress: () => Effect.void,
|
|
@@ -693,7 +692,7 @@ export class MemoryDriver extends ServiceMap.Service<MemoryDriver>()("effect/clu
|
|
|
693
692
|
const unprocessedWith = (predicate: Predicate<Envelope.Encoded>) => {
|
|
694
693
|
const messages: Array<{
|
|
695
694
|
readonly envelope: Envelope.Encoded
|
|
696
|
-
readonly lastSentReply: Reply.Encoded
|
|
695
|
+
readonly lastSentReply: Option.Option<Reply.Encoded>
|
|
697
696
|
}> = []
|
|
698
697
|
const now = clock.currentTimeMillisUnsafe()
|
|
699
698
|
for (const envelope of unprocessed) {
|
|
@@ -707,12 +706,12 @@ export class MemoryDriver extends ServiceMap.Service<MemoryDriver>()("effect/clu
|
|
|
707
706
|
}
|
|
708
707
|
messages.push({
|
|
709
708
|
envelope,
|
|
710
|
-
lastSentReply: entry?.replies[entry.replies.length - 1]
|
|
709
|
+
lastSentReply: Option.fromNullishOr(entry?.replies[entry.replies.length - 1])
|
|
711
710
|
})
|
|
712
711
|
} else {
|
|
713
712
|
messages.push({
|
|
714
713
|
envelope,
|
|
715
|
-
lastSentReply:
|
|
714
|
+
lastSentReply: Option.none()
|
|
716
715
|
})
|
|
717
716
|
}
|
|
718
717
|
}
|
|
@@ -751,9 +750,11 @@ export class MemoryDriver extends ServiceMap.Service<MemoryDriver>()("effect/clu
|
|
|
751
750
|
if (existing) {
|
|
752
751
|
return SaveResultEncoded.Duplicate({
|
|
753
752
|
originalId: Snowflake.Snowflake(existing.envelope.requestId),
|
|
754
|
-
lastReceivedReply:
|
|
755
|
-
|
|
756
|
-
|
|
753
|
+
lastReceivedReply: Option.fromNullishOr(
|
|
754
|
+
existing.replies.length === 1 && existing.replies[0]._tag === "WithExit"
|
|
755
|
+
? existing.replies[0]
|
|
756
|
+
: existing.lastReceivedChunk
|
|
757
|
+
)
|
|
757
758
|
})
|
|
758
759
|
}
|
|
759
760
|
if (envelope._tag === "Request") {
|
|
@@ -797,7 +798,7 @@ export class MemoryDriver extends ServiceMap.Service<MemoryDriver>()("effect/clu
|
|
|
797
798
|
requestIdForPrimaryKey: (primaryKey) =>
|
|
798
799
|
Effect.sync(() => {
|
|
799
800
|
const entry = requestsByPrimaryKey.get(primaryKey)
|
|
800
|
-
return
|
|
801
|
+
return Option.map(Option.fromNullishOr(entry?.envelope.requestId), Snowflake.Snowflake)
|
|
801
802
|
}),
|
|
802
803
|
repliesFor: (requestIds) => Effect.sync(() => repliesFor(requestIds)),
|
|
803
804
|
repliesForUnfiltered: (requestIds) =>
|
|
@@ -808,7 +809,7 @@ export class MemoryDriver extends ServiceMap.Service<MemoryDriver>()("effect/clu
|
|
|
808
809
|
const now = clock.currentTimeMillisUnsafe()
|
|
809
810
|
const messages = Arr.empty<{
|
|
810
811
|
envelope: Envelope.Encoded
|
|
811
|
-
lastSentReply: Reply.Encoded
|
|
812
|
+
lastSentReply: Option.Option<Reply.Encoded>
|
|
812
813
|
}>()
|
|
813
814
|
for (let index = 0; index < journal.length; index++) {
|
|
814
815
|
const envelope = journal[index]
|
|
@@ -823,12 +824,12 @@ export class MemoryDriver extends ServiceMap.Service<MemoryDriver>()("effect/clu
|
|
|
823
824
|
}
|
|
824
825
|
messages.push({
|
|
825
826
|
envelope,
|
|
826
|
-
lastSentReply: entry.replies[entry.replies.length - 1]
|
|
827
|
+
lastSentReply: Option.fromNullishOr(entry.replies[entry.replies.length - 1])
|
|
827
828
|
})
|
|
828
829
|
} else {
|
|
829
830
|
messages.push({
|
|
830
831
|
envelope,
|
|
831
|
-
lastSentReply:
|
|
832
|
+
lastSentReply: Option.none()
|
|
832
833
|
})
|
|
833
834
|
unprocessed.delete(envelope)
|
|
834
835
|
}
|
|
@@ -906,11 +907,11 @@ export const layerMemory: Layer.Layer<
|
|
|
906
907
|
const EnvelopeWithReply: Schema.Struct<
|
|
907
908
|
{
|
|
908
909
|
readonly envelope: Schema.Decoder<Envelope.PartialRequest | Envelope.AckChunk | Envelope.Interrupt>
|
|
909
|
-
readonly lastSentReply: Schema.
|
|
910
|
+
readonly lastSentReply: Schema.Option<Schema.Codec<Reply.Encoded>>
|
|
910
911
|
}
|
|
911
912
|
> = Schema.Struct({
|
|
912
913
|
envelope: Schema.toCodecJson(Envelope.Partial),
|
|
913
|
-
lastSentReply: Schema.
|
|
914
|
+
lastSentReply: Schema.Option(Reply.Encoded)
|
|
914
915
|
})
|
|
915
916
|
|
|
916
917
|
const decodeEnvelopeWithReply = Schema.decodeEffect(EnvelopeWithReply)
|
|
@@ -352,12 +352,15 @@ export const serialize = <R extends Rpc.Any>(
|
|
|
352
352
|
*/
|
|
353
353
|
export const serializeLastReceived = <R extends Rpc.Any>(
|
|
354
354
|
self: OutgoingRequest<R>
|
|
355
|
-
): Effect.Effect<Encoded
|
|
356
|
-
|
|
357
|
-
|
|
355
|
+
): Effect.Effect<Option.Option<Encoded>, MalformedMessage> => {
|
|
356
|
+
const lastReceivedReply = self.lastReceivedReply
|
|
357
|
+
if (lastReceivedReply._tag === "None") {
|
|
358
|
+
return Effect.succeedNone
|
|
358
359
|
}
|
|
359
360
|
const schema = Reply(self.rpc)
|
|
360
361
|
return MalformedMessage.refail(
|
|
361
|
-
Effect.provideServices(Schema.encodeEffect(schema)(
|
|
362
|
+
Effect.provideServices(Schema.encodeEffect(schema)(lastReceivedReply.value), self.services)
|
|
363
|
+
).pipe(
|
|
364
|
+
Effect.map(Option.some)
|
|
362
365
|
)
|
|
363
366
|
}
|
|
@@ -6,6 +6,7 @@ import type * as Exit from "../../Exit.ts"
|
|
|
6
6
|
import * as Fiber from "../../Fiber.ts"
|
|
7
7
|
import { constant } from "../../Function.ts"
|
|
8
8
|
import * as Layer from "../../Layer.ts"
|
|
9
|
+
import * as Option from "../../Option.ts"
|
|
9
10
|
import * as Queue from "../../Queue.ts"
|
|
10
11
|
import * as RpcServer from "../rpc/RpcServer.ts"
|
|
11
12
|
import type * as ClusterError from "./ClusterError.ts"
|
|
@@ -36,23 +37,19 @@ export const layerHandlers = Runners.Rpcs.toLayer(Effect.gen(function*() {
|
|
|
36
37
|
? new Message.IncomingRequest({
|
|
37
38
|
envelope,
|
|
38
39
|
respond: constVoid,
|
|
39
|
-
lastSentReply:
|
|
40
|
+
lastSentReply: Option.none()
|
|
40
41
|
})
|
|
41
42
|
: new Message.IncomingEnvelope({ envelope })
|
|
42
43
|
),
|
|
43
44
|
Effect: ({ persisted, request }) => {
|
|
44
|
-
let replyEncoded:
|
|
45
|
-
|
|
46
|
-
Reply.Encoded,
|
|
47
|
-
ClusterError.EntityNotAssignedToRunner
|
|
48
|
-
>
|
|
49
|
-
| undefined = undefined
|
|
45
|
+
let replyEncoded: Option.Option<Effect.Effect<Reply.Encoded, ClusterError.EntityNotAssignedToRunner>> = Option
|
|
46
|
+
.none()
|
|
50
47
|
let resume = (reply: Effect.Effect<Reply.Encoded, ClusterError.EntityNotAssignedToRunner>) => {
|
|
51
|
-
replyEncoded = reply
|
|
48
|
+
replyEncoded = Option.some(reply)
|
|
52
49
|
}
|
|
53
50
|
const message = new Message.IncomingRequest({
|
|
54
51
|
envelope: request,
|
|
55
|
-
lastSentReply:
|
|
52
|
+
lastSentReply: Option.none(),
|
|
56
53
|
respond(reply) {
|
|
57
54
|
resume(Effect.orDie(Reply.serialize(reply)))
|
|
58
55
|
return Effect.void
|
|
@@ -89,8 +86,8 @@ export const layerHandlers = Runners.Rpcs.toLayer(Effect.gen(function*() {
|
|
|
89
86
|
return Effect.andThen(
|
|
90
87
|
sharding.send(message),
|
|
91
88
|
Effect.callback<Reply.Encoded, ClusterError.EntityNotAssignedToRunner>((resume_) => {
|
|
92
|
-
if (replyEncoded) {
|
|
93
|
-
resume_(replyEncoded)
|
|
89
|
+
if (Option.isSome(replyEncoded)) {
|
|
90
|
+
resume_(replyEncoded.value)
|
|
94
91
|
} else {
|
|
95
92
|
resume = resume_
|
|
96
93
|
}
|
|
@@ -103,7 +100,7 @@ export const layerHandlers = Runners.Rpcs.toLayer(Effect.gen(function*() {
|
|
|
103
100
|
(queue) => {
|
|
104
101
|
const message = new Message.IncomingRequest({
|
|
105
102
|
envelope: request,
|
|
106
|
-
lastSentReply:
|
|
103
|
+
lastSentReply: Option.none(),
|
|
107
104
|
respond(reply) {
|
|
108
105
|
return Effect.flatMap(Reply.serialize(reply), (reply) => {
|
|
109
106
|
Queue.offerUnsafe(queue, reply)
|
|
@@ -191,6 +188,6 @@ export const layerClientOnly: Layer.Layer<
|
|
|
191
188
|
Layer.provide(RunnerHealth.layerNoop),
|
|
192
189
|
Layer.updateService(ShardingConfig, (config) => ({
|
|
193
190
|
...config,
|
|
194
|
-
runnerAddress:
|
|
191
|
+
runnerAddress: Option.none()
|
|
195
192
|
}))
|
|
196
193
|
)
|
|
@@ -5,6 +5,7 @@ import * as Effect from "../../Effect.ts"
|
|
|
5
5
|
import * as Exit from "../../Exit.ts"
|
|
6
6
|
import * as Latch from "../../Latch.ts"
|
|
7
7
|
import * as Layer from "../../Layer.ts"
|
|
8
|
+
import * as Option from "../../Option.ts"
|
|
8
9
|
import * as Queue from "../../Queue.ts"
|
|
9
10
|
import * as RcMap from "../../RcMap.ts"
|
|
10
11
|
import * as Schema from "../../Schema.ts"
|
|
@@ -80,7 +81,7 @@ export class Runners extends ServiceMap.Service<Runners, {
|
|
|
80
81
|
*/
|
|
81
82
|
readonly notify: <R extends Rpc.Any>(
|
|
82
83
|
options: {
|
|
83
|
-
readonly address: RunnerAddress
|
|
84
|
+
readonly address: Option.Option<RunnerAddress>
|
|
84
85
|
readonly message: Message.Outgoing<R>
|
|
85
86
|
readonly discard: boolean
|
|
86
87
|
}
|
|
@@ -166,8 +167,8 @@ export const make: (options: Omit<Runners["Service"], "sendLocal" | "notifyLocal
|
|
|
166
167
|
Duplicate: ({ lastReceivedReply, originalId }) => {
|
|
167
168
|
// If the last received reply is an exit, we can just return it
|
|
168
169
|
// as the response.
|
|
169
|
-
if (lastReceivedReply && lastReceivedReply._tag === "WithExit") {
|
|
170
|
-
return message.respond(lastReceivedReply.withRequestId(message.envelope.requestId))
|
|
170
|
+
if (Option.isSome(lastReceivedReply) && lastReceivedReply.value._tag === "WithExit") {
|
|
171
|
+
return message.respond(lastReceivedReply.value.withRequestId(message.envelope.requestId))
|
|
171
172
|
}
|
|
172
173
|
requestIdRewrites.set(message.envelope.requestId, originalId)
|
|
173
174
|
return afterPersist(
|
|
@@ -341,10 +342,10 @@ export const make: (options: Omit<Runners["Service"], "sendLocal" | "notifyLocal
|
|
|
341
342
|
return notifyWith(message, (message, duplicate) => {
|
|
342
343
|
if (discard || message._tag === "OutgoingEnvelope") {
|
|
343
344
|
return options.notify(options_)
|
|
344
|
-
} else if (!duplicate && options_.address) {
|
|
345
|
+
} else if (!duplicate && Option.isSome(options_.address)) {
|
|
345
346
|
return Effect.catch(
|
|
346
347
|
options.send({
|
|
347
|
-
address: options_.address,
|
|
348
|
+
address: options_.address.value,
|
|
348
349
|
message
|
|
349
350
|
}),
|
|
350
351
|
(_) => replyFromStorage(message)
|
|
@@ -584,11 +585,11 @@ export const makeRpc: Effect.Effect<
|
|
|
584
585
|
})
|
|
585
586
|
},
|
|
586
587
|
notify({ address, message }) {
|
|
587
|
-
if (
|
|
588
|
+
if (Option.isNone(address)) {
|
|
588
589
|
return Effect.void
|
|
589
590
|
}
|
|
590
591
|
const envelope = message.envelope
|
|
591
|
-
return RcMap.get(clients, address).pipe(
|
|
592
|
+
return RcMap.get(clients, address.value).pipe(
|
|
592
593
|
Effect.flatMap((client) => client.Notify({ envelope })),
|
|
593
594
|
Effect.scoped,
|
|
594
595
|
Effect.ignore
|