effect 4.0.3 → 4.0.5
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/AGENTS.md +24 -0
- package/CLAUDE.md +24 -0
- package/ai-docs/package.json +2 -2
- package/ai-docs/src/52_graphql/10_basics.ts +117 -0
- package/ai-docs/src/52_graphql/20_testing.ts +45 -0
- package/ai-docs/src/52_graphql/30_batching.ts +118 -0
- package/ai-docs/src/52_graphql/40_aliased-batching.ts +124 -0
- package/ai-docs/src/52_graphql/50_errors-and-retries.ts +74 -0
- package/ai-docs/src/52_graphql/index.md +6 -0
- package/dist/Array.d.ts +90 -6
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +4 -2
- package/dist/Array.js.map +1 -1
- package/dist/Channel.d.ts +6 -1
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +17 -3
- package/dist/Channel.js.map +1 -1
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +33 -32
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +9 -0
- package/dist/Context.js.map +1 -1
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +2 -5
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +61 -19
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +58 -39
- package/dist/Effect.js.map +1 -1
- package/dist/FileSystem.d.ts +23 -9
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js.map +1 -1
- package/dist/Match.d.ts +20 -6
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +2 -2
- package/dist/Match.js.map +1 -1
- package/dist/Path.d.ts +37 -5
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +36 -5
- package/dist/Path.js.map +1 -1
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +4 -10
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Scheduler.d.ts +9 -0
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +9 -0
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +15 -2
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +16 -2
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaGetter.d.ts +4 -0
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +52 -33
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +38 -17
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +11 -0
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +16 -1
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +12 -0
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +17 -4
- package/dist/String.js.map +1 -1
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +3 -2
- package/dist/TxRef.js.map +1 -1
- package/dist/Utils.js +8 -3
- package/dist/Utils.js.map +1 -1
- package/dist/ai/AiError.d.ts +10 -10
- package/dist/ai/AiError.d.ts.map +1 -1
- package/dist/ai/AiError.js +1 -1
- package/dist/ai/AiError.js.map +1 -1
- package/dist/ai/AnthropicStructuredOutput.js +0 -2
- package/dist/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/ai/Chat.d.ts +2 -2
- package/dist/ai/Chat.d.ts.map +1 -1
- package/dist/ai/Decision.d.ts +70 -19
- package/dist/ai/Decision.d.ts.map +1 -1
- package/dist/ai/Decision.js +37 -3
- package/dist/ai/Decision.js.map +1 -1
- package/dist/ai/DecisionModel.js +1 -1
- package/dist/ai/DecisionModel.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts +38 -7
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +70 -40
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpServer.d.ts +61 -52
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +134 -50
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +28 -5
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Response.d.ts +5 -4
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js.map +1 -1
- package/dist/cli/Completions.d.ts +5 -0
- package/dist/cli/Completions.d.ts.map +1 -1
- package/dist/cli/Completions.js.map +1 -1
- package/dist/cli/Flag.d.ts +100 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +33 -0
- package/dist/cli/Flag.js.map +1 -1
- package/dist/cli/Param.d.ts +87 -0
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +30 -0
- package/dist/cli/Param.js.map +1 -1
- package/dist/cli/internal/command.d.ts.map +1 -1
- package/dist/cli/internal/command.js +2 -1
- package/dist/cli/internal/command.js.map +1 -1
- package/dist/cli/internal/completions/bash.js +4 -3
- package/dist/cli/internal/completions/bash.js.map +1 -1
- package/dist/cli/internal/completions/descriptor.js +8 -1
- package/dist/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/cli/internal/completions/fish.js +4 -4
- package/dist/cli/internal/completions/fish.js.map +1 -1
- package/dist/cli/internal/completions/powershell.js +3 -2
- package/dist/cli/internal/completions/powershell.js.map +1 -1
- package/dist/cli/internal/completions/zsh.js +7 -3
- package/dist/cli/internal/completions/zsh.js.map +1 -1
- package/dist/cli/internal/parser.js +11 -3
- package/dist/cli/internal/parser.js.map +1 -1
- package/dist/cli/internal/wizard.d.ts.map +1 -1
- package/dist/cli/internal/wizard.js +2 -1
- package/dist/cli/internal/wizard.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts +1 -0
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +113 -21
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +20 -12
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Runners.d.ts.map +1 -1
- package/dist/cluster/Runners.js +54 -34
- package/dist/cluster/Runners.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +6 -4
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +1 -1
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/encoding/Sse.d.ts +6 -0
- package/dist/encoding/Sse.d.ts.map +1 -1
- package/dist/encoding/Sse.js +63 -71
- package/dist/encoding/Sse.js.map +1 -1
- package/dist/graphql/GraphQL.d.ts +349 -0
- package/dist/graphql/GraphQL.d.ts.map +1 -0
- package/dist/graphql/GraphQL.js +207 -0
- package/dist/graphql/GraphQL.js.map +1 -0
- package/dist/graphql/GraphQLClient.d.ts +562 -0
- package/dist/graphql/GraphQLClient.d.ts.map +1 -0
- package/dist/graphql/GraphQLClient.js +505 -0
- package/dist/graphql/GraphQLClient.js.map +1 -0
- package/dist/graphql/GraphQLClientError.d.ts +445 -0
- package/dist/graphql/GraphQLClientError.d.ts.map +1 -0
- package/dist/graphql/GraphQLClientError.js +479 -0
- package/dist/graphql/GraphQLClientError.js.map +1 -0
- package/dist/graphql/GraphQLGroup.d.ts +118 -0
- package/dist/graphql/GraphQLGroup.d.ts.map +1 -0
- package/dist/graphql/GraphQLGroup.js +109 -0
- package/dist/graphql/GraphQLGroup.js.map +1 -0
- package/dist/graphql/GraphQLMiddleware.d.ts +249 -0
- package/dist/graphql/GraphQLMiddleware.d.ts.map +1 -0
- package/dist/graphql/GraphQLMiddleware.js +130 -0
- package/dist/graphql/GraphQLMiddleware.js.map +1 -0
- package/dist/graphql/GraphQLProtocol.d.ts +969 -0
- package/dist/graphql/GraphQLProtocol.d.ts.map +1 -0
- package/dist/graphql/GraphQLProtocol.js +809 -0
- package/dist/graphql/GraphQLProtocol.js.map +1 -0
- package/dist/graphql/GraphQLResolver.d.ts +453 -0
- package/dist/graphql/GraphQLResolver.d.ts.map +1 -0
- package/dist/graphql/GraphQLResolver.js +582 -0
- package/dist/graphql/GraphQLResolver.js.map +1 -0
- package/dist/graphql/index.d.ts +40 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +41 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/http/FetchHttpClient.d.ts +6 -3
- package/dist/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/http/FetchHttpClient.js +6 -3
- package/dist/http/FetchHttpClient.js.map +1 -1
- package/dist/http/FindMyWay/internal/router.js +2 -1
- package/dist/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/http/Headers.d.ts +3 -3
- package/dist/http/Headers.d.ts.map +1 -1
- package/dist/http/Headers.js +6 -5
- package/dist/http/Headers.js.map +1 -1
- package/dist/http/HttpClient.d.ts +27 -0
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +38 -11
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +8 -6
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts +147 -4
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +47 -1
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpEffect.d.ts.map +1 -1
- package/dist/http/HttpEffect.js +14 -7
- package/dist/http/HttpEffect.js.map +1 -1
- package/dist/http/HttpMiddleware.d.ts +60 -0
- package/dist/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +93 -32
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpRouter.d.ts +35 -0
- package/dist/http/HttpRouter.d.ts.map +1 -1
- package/dist/http/HttpRouter.js +87 -13
- package/dist/http/HttpRouter.js.map +1 -1
- package/dist/http/HttpServerError.d.ts.map +1 -1
- package/dist/http/HttpServerError.js +6 -4
- package/dist/http/HttpServerError.js.map +1 -1
- package/dist/http/HttpServerRequest.js +2 -2
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/HttpServerResponse.d.ts +8 -6
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +27 -16
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/http/HttpStaticServer.js +4 -10
- package/dist/http/HttpStaticServer.js.map +1 -1
- package/dist/http/HttpTraceContext.js +1 -1
- package/dist/http/HttpTraceContext.js.map +1 -1
- package/dist/http/Multipart.d.ts.map +1 -1
- package/dist/http/Multipart.js +15 -1
- package/dist/http/Multipart.js.map +1 -1
- package/dist/http/Url.d.ts.map +1 -1
- package/dist/http/Url.js +2 -1
- package/dist/http/Url.js.map +1 -1
- package/dist/http/UrlParams.d.ts +112 -8
- package/dist/http/UrlParams.d.ts.map +1 -1
- package/dist/http/UrlParams.js +141 -14
- package/dist/http/UrlParams.js.map +1 -1
- package/dist/http/internal/compression.d.ts +1 -1
- package/dist/http/internal/compression.d.ts.map +1 -1
- package/dist/http/internal/compression.js +2 -10
- package/dist/http/internal/compression.js.map +1 -1
- package/dist/http/internal/compressionBody.d.ts +2 -0
- package/dist/http/internal/compressionBody.d.ts.map +1 -0
- package/dist/http/internal/compressionBody.js +36 -0
- package/dist/http/internal/compressionBody.js.map +1 -0
- package/dist/http/internal/decompression.d.ts +2 -0
- package/dist/http/internal/decompression.d.ts.map +1 -0
- package/dist/http/internal/decompression.js +162 -0
- package/dist/http/internal/decompression.js.map +1 -0
- package/dist/http/internal/tracing.js +14 -4
- package/dist/http/internal/tracing.js.map +1 -1
- package/dist/http/internal/urlParams.d.ts +2 -0
- package/dist/http/internal/urlParams.d.ts.map +1 -0
- package/dist/http/internal/urlParams.js +4 -0
- package/dist/http/internal/urlParams.js.map +1 -0
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +2 -1
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiScalar.d.ts +5 -0
- package/dist/http-api/HttpApiScalar.d.ts.map +1 -1
- package/dist/http-api/HttpApiScalar.js.map +1 -1
- package/dist/internal/core.js +17 -1
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +40 -35
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +13 -6
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/graphql.d.ts +2 -0
- package/dist/internal/graphql.d.ts.map +1 -0
- package/dist/internal/graphql.js +205 -0
- package/dist/internal/graphql.js.map +1 -0
- package/dist/internal/graphqlHeaders.d.ts +4 -0
- package/dist/internal/graphqlHeaders.d.ts.map +1 -0
- package/dist/internal/graphqlHeaders.js +11 -0
- package/dist/internal/graphqlHeaders.js.map +1 -0
- package/dist/internal/request.js +20 -1
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +4 -1
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toJsonSchemaDocument.js +29 -5
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/net/Host.d.ts +49 -0
- package/dist/net/Host.d.ts.map +1 -1
- package/dist/net/Host.js +55 -0
- package/dist/net/Host.js.map +1 -1
- package/dist/net/NetAddress.d.ts +8 -0
- package/dist/net/NetAddress.d.ts.map +1 -1
- package/dist/net/NetAddress.js +8 -0
- package/dist/net/NetAddress.js.map +1 -1
- package/dist/observability/Otlp.d.ts +15 -0
- package/dist/observability/Otlp.d.ts.map +1 -1
- package/dist/observability/Otlp.js +3 -0
- package/dist/observability/Otlp.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts +8 -0
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +10 -1
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpLogger.d.ts +17 -0
- package/dist/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/observability/OtlpLogger.js +14 -1
- package/dist/observability/OtlpLogger.js.map +1 -1
- package/dist/observability/OtlpMetrics.d.ts +17 -0
- package/dist/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/observability/OtlpMetrics.js +13 -0
- package/dist/observability/OtlpMetrics.js.map +1 -1
- package/dist/observability/OtlpTracer.d.ts +17 -0
- package/dist/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/observability/OtlpTracer.js +15 -2
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/reactivity/AsyncResult.d.ts +6 -0
- package/dist/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/reactivity/AsyncResult.js +27 -0
- package/dist/reactivity/AsyncResult.js.map +1 -1
- package/dist/reactivity/AtomRegistry.js +3 -1
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +6 -1
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +36 -9
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/socket/Socket.d.ts +6 -0
- package/dist/socket/Socket.d.ts.map +1 -1
- package/dist/socket/Socket.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +8 -7
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +8 -7
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/testing/TestClock.d.ts +16 -3
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +112 -22
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/workflow/Activity.js +1 -0
- package/dist/workflow/Activity.js.map +1 -1
- package/dist/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/workflow/DurableDeferred.js +32 -3
- package/dist/workflow/DurableDeferred.js.map +1 -1
- package/dist/workflow/Workflow.d.ts +22 -0
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js +15 -3
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts +44 -3
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +45 -22
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +6 -3
- package/src/Array.ts +95 -6
- package/src/Channel.ts +24 -3
- package/src/ConfigProvider.ts +40 -44
- package/src/Context.ts +9 -0
- package/src/Duration.ts +4 -5
- package/src/Effect.ts +140 -53
- package/src/FileSystem.ts +23 -9
- package/src/Match.ts +65 -12
- package/src/Path.ts +52 -7
- package/src/RequestResolver.ts +4 -10
- package/src/Scheduler.ts +9 -0
- package/src/Schema.ts +25 -4
- package/src/SchemaGetter.ts +47 -35
- package/src/Sink.ts +45 -18
- package/src/Stream.ts +33 -4
- package/src/String.ts +17 -4
- package/src/TxRef.ts +4 -2
- package/src/Utils.ts +8 -5
- package/src/ai/AiError.ts +3 -1
- package/src/ai/AnthropicStructuredOutput.ts +2 -2
- package/src/ai/Chat.ts +2 -2
- package/src/ai/Decision.ts +70 -21
- package/src/ai/DecisionModel.ts +1 -1
- package/src/ai/LanguageModel.ts +141 -63
- package/src/ai/McpServer.ts +259 -145
- package/src/ai/Prompt.ts +24 -10
- package/src/ai/Response.ts +6 -3
- package/src/cli/Completions.ts +5 -0
- package/src/cli/Flag.ts +101 -0
- package/src/cli/Param.ts +96 -0
- package/src/cli/internal/command.ts +2 -1
- package/src/cli/internal/completions/bash.ts +4 -3
- package/src/cli/internal/completions/descriptor.ts +10 -1
- package/src/cli/internal/completions/fish.ts +4 -4
- package/src/cli/internal/completions/powershell.ts +5 -2
- package/src/cli/internal/completions/zsh.ts +7 -3
- package/src/cli/internal/parser.ts +12 -3
- package/src/cli/internal/wizard.ts +2 -1
- package/src/cluster/ClusterWorkflowEngine.ts +143 -36
- package/src/cluster/MessageStorage.ts +14 -3
- package/src/cluster/Runners.ts +88 -66
- package/src/cluster/Sharding.ts +12 -9
- package/src/cluster/internal/entityManager.ts +1 -1
- package/src/encoding/Sse.ts +70 -80
- package/src/graphql/GraphQL.ts +494 -0
- package/src/graphql/GraphQLClient.ts +924 -0
- package/src/graphql/GraphQLClientError.ts +542 -0
- package/src/graphql/GraphQLGroup.ts +167 -0
- package/src/graphql/GraphQLMiddleware.ts +253 -0
- package/src/graphql/GraphQLProtocol.ts +1540 -0
- package/src/graphql/GraphQLResolver.ts +1038 -0
- package/src/graphql/index.ts +48 -0
- package/src/http/FetchHttpClient.ts +6 -3
- package/src/http/FindMyWay/internal/router.ts +2 -1
- package/src/http/Headers.ts +6 -9
- package/src/http/HttpClient.ts +72 -11
- package/src/http/HttpClientError.ts +10 -6
- package/src/http/HttpClientRequest.ts +173 -7
- package/src/http/HttpEffect.ts +11 -5
- package/src/http/HttpMiddleware.ts +113 -34
- package/src/http/HttpRouter.ts +95 -13
- package/src/http/HttpServerError.ts +8 -4
- package/src/http/HttpServerRequest.ts +2 -2
- package/src/http/HttpServerResponse.ts +28 -16
- package/src/http/HttpStaticServer.ts +4 -10
- package/src/http/HttpTraceContext.ts +1 -1
- package/src/http/Multipart.ts +17 -1
- package/src/http/Url.ts +2 -1
- package/src/http/UrlParams.ts +225 -26
- package/src/http/internal/compression.ts +3 -17
- package/src/http/internal/compressionBody.ts +56 -0
- package/src/http/internal/decompression.ts +226 -0
- package/src/http/internal/tracing.ts +21 -4
- package/src/http/internal/urlParams.ts +5 -0
- package/src/http-api/HttpApiClient.ts +2 -1
- package/src/http-api/HttpApiScalar.ts +5 -0
- package/src/internal/core.ts +21 -1
- package/src/internal/dateTime.ts +13 -10
- package/src/internal/effect.ts +13 -7
- package/src/internal/graphql.ts +286 -0
- package/src/internal/graphqlHeaders.ts +11 -0
- package/src/internal/request.ts +31 -3
- package/src/internal/schema/toCodeDocument.ts +7 -1
- package/src/internal/schema/toJsonSchemaDocument.ts +34 -2
- package/src/internal/version.ts +1 -1
- package/src/net/Host.ts +72 -0
- package/src/net/NetAddress.ts +9 -0
- package/src/observability/Otlp.ts +18 -0
- package/src/observability/OtlpExporter.ts +14 -3
- package/src/observability/OtlpLogger.ts +31 -2
- package/src/observability/OtlpMetrics.ts +30 -1
- package/src/observability/OtlpTracer.ts +32 -3
- package/src/reactivity/AsyncResult.ts +31 -0
- package/src/reactivity/AtomRegistry.ts +3 -1
- package/src/rpc/RpcClient.ts +6 -1
- package/src/rpc/RpcServer.ts +55 -15
- package/src/socket/Socket.ts +6 -0
- package/src/sql/SqlClient.ts +9 -7
- package/src/testing/TestClock.ts +144 -29
- package/src/workflow/Activity.ts +1 -0
- package/src/workflow/DurableDeferred.ts +43 -5
- package/src/workflow/Workflow.ts +31 -5
- package/src/workflow/WorkflowEngine.ts +107 -25
|
@@ -52,6 +52,11 @@ export const make: (
|
|
|
52
52
|
readonly attributes?: Record<string, unknown>
|
|
53
53
|
} | undefined
|
|
54
54
|
readonly headers?: Headers.Input | undefined
|
|
55
|
+
/**
|
|
56
|
+
* Request compression. Defaults to "none". Gzip uses
|
|
57
|
+
* HttpClientRequest's default minimum body size of 1KB.
|
|
58
|
+
*/
|
|
59
|
+
readonly compression?: "gzip" | "none" | undefined
|
|
55
60
|
readonly exportInterval?: Duration.Input | undefined
|
|
56
61
|
readonly maxBatchSize?: number | undefined
|
|
57
62
|
readonly shutdownTimeout?: Duration.Input | undefined
|
|
@@ -73,6 +78,7 @@ export const make: (
|
|
|
73
78
|
label: "OtlpLogger",
|
|
74
79
|
url: options.url,
|
|
75
80
|
headers: options.headers,
|
|
81
|
+
compression: options.compression,
|
|
76
82
|
maxBatchSize: options.maxBatchSize ?? 1000,
|
|
77
83
|
exportInterval: options.exportInterval ?? Duration.seconds(1),
|
|
78
84
|
body: (data) => [
|
|
@@ -118,6 +124,11 @@ export const layer = (options: {
|
|
|
118
124
|
readonly attributes?: Record<string, unknown>
|
|
119
125
|
} | undefined
|
|
120
126
|
readonly headers?: Headers.Input | undefined
|
|
127
|
+
/**
|
|
128
|
+
* Request compression. Defaults to "none". Gzip uses
|
|
129
|
+
* HttpClientRequest's default minimum body size of 1KB.
|
|
130
|
+
*/
|
|
131
|
+
readonly compression?: "gzip" | "none" | undefined
|
|
121
132
|
readonly exportInterval?: Duration.Input | undefined
|
|
122
133
|
readonly maxBatchSize?: number | undefined
|
|
123
134
|
readonly shutdownTimeout?: Duration.Input | undefined
|
|
@@ -131,6 +142,13 @@ export const layer = (options: {
|
|
|
131
142
|
/**
|
|
132
143
|
* Creates an OTLP logs layer from OpenTelemetry configuration.
|
|
133
144
|
*
|
|
145
|
+
* **Details**
|
|
146
|
+
*
|
|
147
|
+
* Compression accepts "gzip" or "none".
|
|
148
|
+
* `OTEL_EXPORTER_OTLP_LOGS_COMPRESSION` takes precedence over
|
|
149
|
+
* `OTEL_EXPORTER_OTLP_COMPRESSION`, defaulting to "none". Gzip uses
|
|
150
|
+
* HttpClientRequest's default minimum body size of 1KB.
|
|
151
|
+
*
|
|
134
152
|
* @stability unstable
|
|
135
153
|
* @category layers
|
|
136
154
|
* @since 4.0.0
|
|
@@ -156,7 +174,17 @@ export const layerFromConfig = (options?: {
|
|
|
156
174
|
return Exporter.layerFlusher
|
|
157
175
|
}
|
|
158
176
|
|
|
159
|
-
const {
|
|
177
|
+
const {
|
|
178
|
+
baseCompression,
|
|
179
|
+
compression,
|
|
180
|
+
baseTimeout,
|
|
181
|
+
logsTimeout,
|
|
182
|
+
exportTimeout,
|
|
183
|
+
scheduleDelay,
|
|
184
|
+
maxBatchSize
|
|
185
|
+
} = yield* Config.all({
|
|
186
|
+
baseCompression: Config.option(Config.Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_COMPRESSION")),
|
|
187
|
+
compression: Config.option(Config.Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_LOGS_COMPRESSION")),
|
|
160
188
|
baseTimeout: Config.option(Config.Int("OTEL_EXPORTER_OTLP_TIMEOUT")),
|
|
161
189
|
logsTimeout: Config.option(Config.Int("OTEL_EXPORTER_OTLP_LOGS_TIMEOUT")),
|
|
162
190
|
exportTimeout: Config.option(Config.Int("OTEL_BLRP_EXPORT_TIMEOUT")),
|
|
@@ -173,6 +201,7 @@ export const layerFromConfig = (options?: {
|
|
|
173
201
|
url: endpoint.toString(),
|
|
174
202
|
resource: options?.resource,
|
|
175
203
|
headers: options?.headers ?? (yield* OtlpEnv.headers("LOGS")),
|
|
204
|
+
compression: Option.getOrElse(Option.firstSomeOf([compression, baseCompression]), () => "none" as const),
|
|
176
205
|
exportInterval: Option.getOrUndefined(exportInterval),
|
|
177
206
|
maxBatchSize: Option.getOrUndefined(maxBatchSize),
|
|
178
207
|
shutdownTimeout: Option.getOrUndefined(shutdownTimeout),
|
|
@@ -232,7 +261,7 @@ const makeLogRecord = (options: Logger.Options<unknown>, opts: {
|
|
|
232
261
|
}
|
|
233
262
|
|
|
234
263
|
if (options.fiber.cache.span) {
|
|
235
|
-
logRecord.traceId = options.fiber.cache.span.traceId
|
|
264
|
+
logRecord.traceId = options.fiber.cache.span.traceId.padStart(32, "0")
|
|
236
265
|
logRecord.spanId = options.fiber.cache.span.spanId
|
|
237
266
|
}
|
|
238
267
|
|
|
@@ -89,6 +89,11 @@ export const make: (options: {
|
|
|
89
89
|
readonly attributes?: Record<string, unknown>
|
|
90
90
|
} | undefined
|
|
91
91
|
readonly headers?: Headers.Input | undefined
|
|
92
|
+
/**
|
|
93
|
+
* Request compression. Defaults to "none". Gzip uses
|
|
94
|
+
* HttpClientRequest's default minimum body size of 1KB.
|
|
95
|
+
*/
|
|
96
|
+
readonly compression?: "gzip" | "none" | undefined
|
|
92
97
|
readonly exportInterval?: Duration.Input | undefined
|
|
93
98
|
readonly shutdownTimeout?: Duration.Input | undefined
|
|
94
99
|
readonly temporality?: AggregationTemporality | undefined
|
|
@@ -387,6 +392,7 @@ export const make: (options: {
|
|
|
387
392
|
label: "OtlpMetrics",
|
|
388
393
|
url: options.url,
|
|
389
394
|
headers: options.headers,
|
|
395
|
+
compression: options.compression,
|
|
390
396
|
maxBatchSize: "disabled",
|
|
391
397
|
exportEmpty: true,
|
|
392
398
|
exportInterval: options.exportInterval ?? Duration.seconds(10),
|
|
@@ -410,6 +416,11 @@ export const layer = (options: {
|
|
|
410
416
|
readonly attributes?: Record<string, unknown>
|
|
411
417
|
} | undefined
|
|
412
418
|
readonly headers?: Headers.Input | undefined
|
|
419
|
+
/**
|
|
420
|
+
* Request compression. Defaults to "none". Gzip uses
|
|
421
|
+
* HttpClientRequest's default minimum body size of 1KB.
|
|
422
|
+
*/
|
|
423
|
+
readonly compression?: "gzip" | "none" | undefined
|
|
413
424
|
readonly exportInterval?: Duration.Input | undefined
|
|
414
425
|
readonly shutdownTimeout?: Duration.Input | undefined
|
|
415
426
|
readonly temporality?: AggregationTemporality | undefined
|
|
@@ -419,6 +430,13 @@ export const layer = (options: {
|
|
|
419
430
|
/**
|
|
420
431
|
* Creates an OTLP metrics layer from OpenTelemetry configuration.
|
|
421
432
|
*
|
|
433
|
+
* **Details**
|
|
434
|
+
*
|
|
435
|
+
* Compression accepts "gzip" or "none".
|
|
436
|
+
* `OTEL_EXPORTER_OTLP_METRICS_COMPRESSION` takes precedence over
|
|
437
|
+
* `OTEL_EXPORTER_OTLP_COMPRESSION`, defaulting to "none". Gzip uses
|
|
438
|
+
* HttpClientRequest's default minimum body size of 1KB.
|
|
439
|
+
*
|
|
422
440
|
* @stability unstable
|
|
423
441
|
* @category layers
|
|
424
442
|
* @since 4.0.0
|
|
@@ -441,7 +459,17 @@ export const layerFromConfig = (options?: {
|
|
|
441
459
|
return Exporter.layerFlusher
|
|
442
460
|
}
|
|
443
461
|
|
|
444
|
-
const {
|
|
462
|
+
const {
|
|
463
|
+
baseCompression,
|
|
464
|
+
compression,
|
|
465
|
+
baseTimeout,
|
|
466
|
+
metricsTimeout,
|
|
467
|
+
exportTimeout,
|
|
468
|
+
exportInterval,
|
|
469
|
+
temporalityPreference
|
|
470
|
+
} = yield* Config.all({
|
|
471
|
+
baseCompression: Config.option(Config.Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_COMPRESSION")),
|
|
472
|
+
compression: Config.option(Config.Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_METRICS_COMPRESSION")),
|
|
445
473
|
baseTimeout: Config.option(Config.Int("OTEL_EXPORTER_OTLP_TIMEOUT")),
|
|
446
474
|
metricsTimeout: Config.option(Config.Int("OTEL_EXPORTER_OTLP_METRICS_TIMEOUT")),
|
|
447
475
|
exportTimeout: Config.option(Config.Int("OTEL_METRIC_EXPORT_TIMEOUT")),
|
|
@@ -463,6 +491,7 @@ export const layerFromConfig = (options?: {
|
|
|
463
491
|
url: endpoint.toString(),
|
|
464
492
|
resource: options?.resource,
|
|
465
493
|
headers: options?.headers ?? (yield* OtlpEnv.headers("METRICS")),
|
|
494
|
+
compression: Option.getOrElse(Option.firstSomeOf([compression, baseCompression]), () => "none" as const),
|
|
466
495
|
exportInterval: Option.getOrUndefined(exportInterval),
|
|
467
496
|
shutdownTimeout: Option.getOrUndefined(shutdownTimeout),
|
|
468
497
|
temporality: Option.getOrUndefined(temporalityPreference)
|
|
@@ -55,6 +55,11 @@ export const make: (
|
|
|
55
55
|
readonly attributes?: Record<string, unknown>
|
|
56
56
|
} | undefined
|
|
57
57
|
readonly headers?: Headers.Input | undefined
|
|
58
|
+
/**
|
|
59
|
+
* Request compression. Defaults to "none". Gzip uses
|
|
60
|
+
* HttpClientRequest's default minimum body size of 1KB.
|
|
61
|
+
*/
|
|
62
|
+
readonly compression?: "gzip" | "none" | undefined
|
|
58
63
|
readonly exportInterval?: Duration.Input | undefined
|
|
59
64
|
readonly maxBatchSize?: number | undefined
|
|
60
65
|
readonly context?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
|
|
@@ -76,6 +81,7 @@ export const make: (
|
|
|
76
81
|
label: "OtlpTracer",
|
|
77
82
|
url: options.url,
|
|
78
83
|
headers: options.headers,
|
|
84
|
+
compression: options.compression,
|
|
79
85
|
exportInterval: options.exportInterval ?? Duration.seconds(5),
|
|
80
86
|
maxBatchSize: options.maxBatchSize ?? 1000,
|
|
81
87
|
body(spans) {
|
|
@@ -128,6 +134,11 @@ export const layer: (options: {
|
|
|
128
134
|
readonly attributes?: Record<string, unknown>
|
|
129
135
|
} | undefined
|
|
130
136
|
readonly headers?: Headers.Input | undefined
|
|
137
|
+
/**
|
|
138
|
+
* Request compression. Defaults to "none". Gzip uses
|
|
139
|
+
* HttpClientRequest's default minimum body size of 1KB.
|
|
140
|
+
*/
|
|
141
|
+
readonly compression?: "gzip" | "none" | undefined
|
|
131
142
|
readonly exportInterval?: Duration.Input | undefined
|
|
132
143
|
readonly maxBatchSize?: number | undefined
|
|
133
144
|
readonly context?: (<X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X) | undefined
|
|
@@ -141,6 +152,13 @@ export const layer: (options: {
|
|
|
141
152
|
/**
|
|
142
153
|
* Creates an OTLP traces layer from OpenTelemetry configuration.
|
|
143
154
|
*
|
|
155
|
+
* **Details**
|
|
156
|
+
*
|
|
157
|
+
* Compression accepts "gzip" or "none".
|
|
158
|
+
* `OTEL_EXPORTER_OTLP_TRACES_COMPRESSION` takes precedence over
|
|
159
|
+
* `OTEL_EXPORTER_OTLP_COMPRESSION`, defaulting to "none". Gzip uses
|
|
160
|
+
* HttpClientRequest's default minimum body size of 1KB.
|
|
161
|
+
*
|
|
144
162
|
* @stability unstable
|
|
145
163
|
* @category layers
|
|
146
164
|
* @since 4.0.0
|
|
@@ -165,7 +183,17 @@ export const layerFromConfig = (options?: {
|
|
|
165
183
|
return Exporter.layerFlusher
|
|
166
184
|
}
|
|
167
185
|
|
|
168
|
-
const {
|
|
186
|
+
const {
|
|
187
|
+
baseCompression,
|
|
188
|
+
compression,
|
|
189
|
+
baseTimeout,
|
|
190
|
+
tracesTimeout,
|
|
191
|
+
exportTimeout,
|
|
192
|
+
scheduleDelay,
|
|
193
|
+
maxBatchSize
|
|
194
|
+
} = yield* Config.all({
|
|
195
|
+
baseCompression: Config.option(Config.Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_COMPRESSION")),
|
|
196
|
+
compression: Config.option(Config.Literals(["gzip", "none"], "OTEL_EXPORTER_OTLP_TRACES_COMPRESSION")),
|
|
169
197
|
baseTimeout: Config.option(Config.Int("OTEL_EXPORTER_OTLP_TIMEOUT")),
|
|
170
198
|
tracesTimeout: Config.option(Config.Int("OTEL_EXPORTER_OTLP_TRACES_TIMEOUT")),
|
|
171
199
|
exportTimeout: Config.option(Config.Int("OTEL_BSP_EXPORT_TIMEOUT")),
|
|
@@ -185,6 +213,7 @@ export const layerFromConfig = (options?: {
|
|
|
185
213
|
url: endpoint.toString(),
|
|
186
214
|
resource: options?.resource,
|
|
187
215
|
headers: options?.headers ?? (yield* OtlpEnv.headers("TRACES")),
|
|
216
|
+
compression: Option.getOrElse(Option.firstSomeOf([compression, baseCompression]), () => "none" as const),
|
|
188
217
|
exportInterval: Option.getOrUndefined(scheduleDelay),
|
|
189
218
|
maxBatchSize: Option.getOrUndefined(maxBatchSize),
|
|
190
219
|
context: options?.context,
|
|
@@ -342,7 +371,7 @@ const makeOtlpSpan = (self: SpanImpl): OtlpSpan => {
|
|
|
342
371
|
for (let i = 0; i < self.links.length; i++) {
|
|
343
372
|
const link = self.links[i]
|
|
344
373
|
links.push({
|
|
345
|
-
traceId: link.span.traceId,
|
|
374
|
+
traceId: link.span.traceId.padStart(32, "0"),
|
|
346
375
|
spanId: link.span.spanId,
|
|
347
376
|
attributes: entriesToAttributes(Object.entries(link.attributes)),
|
|
348
377
|
droppedAttributesCount: 0
|
|
@@ -350,7 +379,7 @@ const makeOtlpSpan = (self: SpanImpl): OtlpSpan => {
|
|
|
350
379
|
}
|
|
351
380
|
|
|
352
381
|
return {
|
|
353
|
-
traceId: self.traceId,
|
|
382
|
+
traceId: self.traceId.padStart(32, "0"),
|
|
354
383
|
spanId: self.spanId,
|
|
355
384
|
parentSpanId: Option.isSome(self.parent) ? self.parent.value.spanId : undefined,
|
|
356
385
|
name: self.name,
|
|
@@ -901,6 +901,12 @@ export const matchWithWaiting: {
|
|
|
901
901
|
/**
|
|
902
902
|
* Combines an iterable or record of `AsyncResult` and plain values into one `AsyncResult`, returning the first non-success result or a success of the collected values marked waiting when any input success is waiting.
|
|
903
903
|
*
|
|
904
|
+
* **Details**
|
|
905
|
+
*
|
|
906
|
+
* If the first non-success result is a failure, its previous success is
|
|
907
|
+
* rebuilt in the combined shape from each input's current or previous value.
|
|
908
|
+
* It is omitted if any input has no value.
|
|
909
|
+
*
|
|
904
910
|
* @stability unstable
|
|
905
911
|
* @category combinators
|
|
906
912
|
* @since 4.0.0
|
|
@@ -932,6 +938,11 @@ export const all = <const Arg extends Iterable<any> | Record<string, any>>(
|
|
|
932
938
|
if (!isAsyncResult(result)) {
|
|
933
939
|
InternalRecord.assignProperty(successes, key, result)
|
|
934
940
|
continue
|
|
941
|
+
} else if (isFailure(result)) {
|
|
942
|
+
return failure(result.cause, {
|
|
943
|
+
previousSuccess: combinedPreviousSuccess(entries, isIter),
|
|
944
|
+
waiting: result.waiting
|
|
945
|
+
}) as any
|
|
935
946
|
} else if (!isSuccess(result)) {
|
|
936
947
|
return result as any
|
|
937
948
|
}
|
|
@@ -943,6 +954,26 @@ export const all = <const Arg extends Iterable<any> | Record<string, any>>(
|
|
|
943
954
|
return success(successes, { waiting }) as any
|
|
944
955
|
}
|
|
945
956
|
|
|
957
|
+
const combinedPreviousSuccess = (
|
|
958
|
+
entries: ReadonlyArray<readonly [PropertyKey, unknown]>,
|
|
959
|
+
isIter: boolean
|
|
960
|
+
): Option.Option<Success<unknown, never>> => {
|
|
961
|
+
const values: any = isIter ? [] : {}
|
|
962
|
+
for (let i = 0; i < entries.length; i++) {
|
|
963
|
+
const [key, entry] = entries[i]
|
|
964
|
+
if (!isAsyncResult(entry)) {
|
|
965
|
+
InternalRecord.assignProperty(values, key, entry)
|
|
966
|
+
continue
|
|
967
|
+
}
|
|
968
|
+
const entryValue = value(entry)
|
|
969
|
+
if (Option.isNone(entryValue)) {
|
|
970
|
+
return Option.none()
|
|
971
|
+
}
|
|
972
|
+
InternalRecord.assignProperty(values, key, entryValue.value)
|
|
973
|
+
}
|
|
974
|
+
return Option.some(success(values))
|
|
975
|
+
}
|
|
976
|
+
|
|
946
977
|
/**
|
|
947
978
|
* Creates a typed builder for rendering an `AsyncResult` by handling waiting, initial, success, error, defect, interrupt, and failure cases.
|
|
948
979
|
*
|
|
@@ -967,7 +967,9 @@ class NodeImpl<A> {
|
|
|
967
967
|
this._value = value
|
|
968
968
|
let failure: unknown = noFailure
|
|
969
969
|
try {
|
|
970
|
-
|
|
970
|
+
// A first value cannot replace one held by a dependent. Recovery still
|
|
971
|
+
// retries dependents whose reads failed before this node had a value.
|
|
972
|
+
if (initialized || recovered) this.invalidateChildren()
|
|
971
973
|
} catch (error) {
|
|
972
974
|
failure = error
|
|
973
975
|
}
|
package/src/rpc/RpcClient.ts
CHANGED
|
@@ -1249,16 +1249,21 @@ const makePinger = Effect.fnUntraced(function*<A, E, R>(writePing: Effect.Effect
|
|
|
1249
1249
|
const interval = options?.pingInterval ?? "5 seconds"
|
|
1250
1250
|
const timeoutMillis = Duration.toMillis(options?.pingTimeout ?? interval)
|
|
1251
1251
|
let lastSeen = clock.currentTimeMillisUnsafe()
|
|
1252
|
+
let awaitingResponse = false
|
|
1252
1253
|
const latch = Latch.makeUnsafe()
|
|
1253
1254
|
const onFrame = () => {
|
|
1254
1255
|
lastSeen = clock.currentTimeMillisUnsafe()
|
|
1256
|
+
awaitingResponse = false
|
|
1255
1257
|
}
|
|
1256
1258
|
const reset = () => {
|
|
1257
1259
|
onFrame()
|
|
1258
1260
|
latch.closeUnsafe()
|
|
1259
1261
|
}
|
|
1260
1262
|
yield* Effect.suspend((): Effect.Effect<void, E, R> => {
|
|
1261
|
-
|
|
1263
|
+
// A late tick must send a ping before it can declare the connection silent.
|
|
1264
|
+
// Keep the timeout measured from the last frame, including for custom timeouts.
|
|
1265
|
+
if (awaitingResponse && clock.currentTimeMillisUnsafe() - lastSeen > timeoutMillis) return latch.open
|
|
1266
|
+
awaitingResponse = true
|
|
1262
1267
|
return writePing
|
|
1263
1268
|
}).pipe(
|
|
1264
1269
|
Effect.delay(interval),
|
package/src/rpc/RpcServer.ts
CHANGED
|
@@ -494,6 +494,57 @@ export const makeNoSerialization: <Rpcs extends Rpc.Any>(
|
|
|
494
494
|
})
|
|
495
495
|
})
|
|
496
496
|
|
|
497
|
+
// Built-in JSON codecs depend only on the RPC schemas and can be shared.
|
|
498
|
+
// Other factories may capture state at construction, so keep them per server.
|
|
499
|
+
const isSharedCodecFor = (codecFor: RpcSerialization.CodecFor) => codecFor === RpcSerialization.json.codecFor
|
|
500
|
+
|
|
501
|
+
interface RpcCodecs {
|
|
502
|
+
readonly decode: (u: unknown) => Effect.Effect<any, Schema.SchemaError>
|
|
503
|
+
readonly encodeChunk: (
|
|
504
|
+
u: NonEmptyReadonlyArray<unknown>
|
|
505
|
+
) => Effect.Effect<NonEmptyReadonlyArray<unknown>, Schema.SchemaError>
|
|
506
|
+
readonly encodeExit: (u: unknown) => Effect.Effect<ResponseExitEncoded["exit"], Schema.SchemaError>
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
const sharedRpcCodecs = new WeakMap<Rpc.AnyWithProps, RpcCodecs>()
|
|
510
|
+
|
|
511
|
+
const rpcCodecs = (codecFor: RpcSerialization.CodecFor, rpc: Rpc.AnyWithProps): RpcCodecs => {
|
|
512
|
+
const shared = isSharedCodecFor(codecFor)
|
|
513
|
+
let codecs = shared ? sharedRpcCodecs.get(rpc) : undefined
|
|
514
|
+
if (codecs === undefined) {
|
|
515
|
+
const streamSchemas = RpcSchema.getStreamSchemas(rpc.successSchema)
|
|
516
|
+
codecs = {
|
|
517
|
+
decode: Schema.decodeUnknownEffect(codecFor(rpc.payloadSchema)) as any,
|
|
518
|
+
encodeChunk: Schema.encodeUnknownEffect(
|
|
519
|
+
codecFor(
|
|
520
|
+
Schema.NonEmptyArray(Option.isSome(streamSchemas) ? streamSchemas.value.success : Schema.Any)
|
|
521
|
+
)
|
|
522
|
+
) as any,
|
|
523
|
+
encodeExit: Schema.encodeUnknownEffect(codecFor(Rpc.exitSchema(rpc as any))) as any
|
|
524
|
+
}
|
|
525
|
+
if (shared) sharedRpcCodecs.set(rpc, codecs)
|
|
526
|
+
}
|
|
527
|
+
return codecs
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
interface DefectCodecs {
|
|
531
|
+
readonly encodeDefectUnsafe: (defect: unknown) => unknown
|
|
532
|
+
readonly encodeUnknownRequestExit: (u: unknown) => Effect.Effect<ResponseExitEncoded["exit"], Schema.SchemaError>
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
let sharedDefectCodecs: DefectCodecs | undefined
|
|
536
|
+
|
|
537
|
+
const makeDefectCodecs = (codecFor: RpcSerialization.CodecFor): DefectCodecs => ({
|
|
538
|
+
encodeDefectUnsafe: Schema.encodeSync(codecFor(Schema.Defect())),
|
|
539
|
+
// Unknown tags have no RPC schema, so use a defect-only exit schema.
|
|
540
|
+
encodeUnknownRequestExit: Schema.encodeUnknownEffect(
|
|
541
|
+
codecFor(Schema.Exit(Schema.Never, Schema.Never, Schema.Defect()))
|
|
542
|
+
) as any
|
|
543
|
+
})
|
|
544
|
+
|
|
545
|
+
const defectCodecs = (codecFor: RpcSerialization.CodecFor): DefectCodecs =>
|
|
546
|
+
isSharedCodecFor(codecFor) ? (sharedDefectCodecs ??= makeDefectCodecs(codecFor)) : makeDefectCodecs(codecFor)
|
|
547
|
+
|
|
497
548
|
// Merging the handler entry services with the request fiber services costs
|
|
498
549
|
// O(services), so the merged context is cached per (entry, fiber context)
|
|
499
550
|
// pair. Request fibers on persistent connections keep one context across
|
|
@@ -586,11 +637,7 @@ export const make: <Rpcs extends Rpc.Any>(
|
|
|
586
637
|
supportsSpanPropagation,
|
|
587
638
|
supportsTransferables
|
|
588
639
|
} = yield* Protocol
|
|
589
|
-
const encodeDefectUnsafe =
|
|
590
|
-
// Unknown tags have no RPC schema, so use a defect-only exit schema.
|
|
591
|
-
const encodeUnknownRequestExit: Schemas["encodeExit"] = Schema.encodeUnknownEffect(
|
|
592
|
-
codecFor(Schema.Exit(Schema.Never, Schema.Never, Schema.Defect()))
|
|
593
|
-
) as any
|
|
640
|
+
const { encodeDefectUnsafe, encodeUnknownRequestExit } = defectCodecs(codecFor)
|
|
594
641
|
const services = yield* Effect.context<Rpc.ToHandler<Rpcs> | Rpc.Middleware<Rpcs>>()
|
|
595
642
|
const scope = yield* Scope.make()
|
|
596
643
|
|
|
@@ -666,16 +713,9 @@ export const make: <Rpcs extends Rpc.Any>(
|
|
|
666
713
|
let schemas = schemasCache.get(rpc)
|
|
667
714
|
if (!schemas) {
|
|
668
715
|
const entry = Context.getOrUndefinedUnsafe(services, rpc.key) as Rpc.Handler<Rpcs["_tag"]>
|
|
669
|
-
const streamSchemas = RpcSchema.getStreamSchemas(rpc.successSchema)
|
|
670
716
|
schemas = {
|
|
671
717
|
tag: rpc._tag,
|
|
672
|
-
|
|
673
|
-
encodeChunk: Schema.encodeUnknownEffect(
|
|
674
|
-
codecFor(
|
|
675
|
-
Schema.NonEmptyArray(Option.isSome(streamSchemas) ? streamSchemas.value.success : Schema.Any)
|
|
676
|
-
)
|
|
677
|
-
) as any,
|
|
678
|
-
encodeExit: Schema.encodeUnknownEffect(codecFor(Rpc.exitSchema(rpc as any))) as any,
|
|
718
|
+
...rpcCodecs(codecFor, rpc),
|
|
679
719
|
context: entry.context
|
|
680
720
|
}
|
|
681
721
|
schemasCache.set(rpc, schemas)
|
|
@@ -1109,7 +1149,7 @@ export const makeProtocolWithHttpEffect: (
|
|
|
1109
1149
|
RpcSerialization.RpcSerialization
|
|
1110
1150
|
> = Effect.fnUntraced(function*(options = {}) {
|
|
1111
1151
|
const serialization = yield* RpcSerialization.RpcSerialization
|
|
1112
|
-
const encodeDefectUnsafe =
|
|
1152
|
+
const { encodeDefectUnsafe } = defectCodecs(serialization.codecFor)
|
|
1113
1153
|
const includesFraming = serialization.includesFraming
|
|
1114
1154
|
const isBinary = !serialization.contentType.includes("json")
|
|
1115
1155
|
|
|
@@ -1569,7 +1609,7 @@ const makeSocketProtocol: Effect.Effect<
|
|
|
1569
1609
|
RpcSerialization.RpcSerialization
|
|
1570
1610
|
> = Effect.gen(function*() {
|
|
1571
1611
|
const serialization = yield* RpcSerialization.RpcSerialization
|
|
1572
|
-
const encodeDefectUnsafe =
|
|
1612
|
+
const { encodeDefectUnsafe } = defectCodecs(serialization.codecFor)
|
|
1573
1613
|
const disconnects = yield* Queue.make<number>()
|
|
1574
1614
|
|
|
1575
1615
|
let clientId = 0
|
package/src/socket/Socket.ts
CHANGED
|
@@ -161,6 +161,12 @@ export interface Writer {
|
|
|
161
161
|
* @since 4.0.0
|
|
162
162
|
*/
|
|
163
163
|
export interface TlsUpgradeOptions {
|
|
164
|
+
/**
|
|
165
|
+
* DNS hostname used for Server Name Indication (SNI) and certificate identity
|
|
166
|
+
* verification during client upgrades. Server upgrades ignore this option.
|
|
167
|
+
* When omitted, the adapter retains its existing hostname behavior.
|
|
168
|
+
*/
|
|
169
|
+
readonly servername?: string | undefined
|
|
164
170
|
readonly key?:
|
|
165
171
|
| Redacted.Redacted<string | Uint8Array>
|
|
166
172
|
| ReadonlyArray<Redacted.Redacted<string | Uint8Array>>
|
package/src/sql/SqlClient.ts
CHANGED
|
@@ -275,22 +275,22 @@ export const make = Effect.fnUntraced(function*(options: SqlClient.MakeOptions)
|
|
|
275
275
|
})
|
|
276
276
|
|
|
277
277
|
/**
|
|
278
|
-
* Builds the acquirers and failed-COMMIT cleanup for a SQLite client that
|
|
278
|
+
* Builds the acquirers, borrower and failed-COMMIT cleanup for a SQLite client that
|
|
279
279
|
* shares one connection through a semaphore.
|
|
280
280
|
*
|
|
281
281
|
* **Details**
|
|
282
282
|
*
|
|
283
283
|
* Both acquirers lease the connection into the current scope and hold the
|
|
284
|
-
* semaphore until that scope closes
|
|
285
|
-
*
|
|
286
|
-
* underneath
|
|
287
|
-
* have to run inside `Effect.scoped`.
|
|
284
|
+
* semaphore until that scope closes. The borrower holds the same semaphore
|
|
285
|
+
* until the statement finishes without creating a scope. Another fiber cannot
|
|
286
|
+
* begin a transaction underneath either. Effects that use the connection directly,
|
|
287
|
+
* such as an export, have to run inside `Effect.scoped`.
|
|
288
288
|
*
|
|
289
289
|
* SQLite can keep a transaction open after COMMIT fails, for example on a
|
|
290
290
|
* deferred foreign key violation. `onCommitFailure` rolls it back before the
|
|
291
291
|
* connection is reused. If that ROLLBACK fails, the connection is rejected, and
|
|
292
|
-
* each acquisition retries the ROLLBACK once while holding the semaphore
|
|
293
|
-
* it succeeds. The database is never reopened, and transactions started with a
|
|
292
|
+
* each acquisition or borrow retries the ROLLBACK once while holding the semaphore
|
|
293
|
+
* until it succeeds. The database is never reopened, and transactions started with a
|
|
294
294
|
* plain `BEGIN` are only touched after a failed cleanup.
|
|
295
295
|
*
|
|
296
296
|
* Pass `isTransaction` when the driver can report whether a transaction is
|
|
@@ -307,6 +307,7 @@ export const makeSqliteAcquirers = <C extends Connection.Connection>(options: {
|
|
|
307
307
|
readonly isTransaction?: ((conn: C) => boolean) | undefined
|
|
308
308
|
}): {
|
|
309
309
|
readonly acquirer: Effect.Effect<C, SqlError, Scope.Scope>
|
|
310
|
+
readonly borrower: Connection.Borrower
|
|
310
311
|
readonly transactionAcquirer: Effect.Effect<C, SqlError, Scope.Scope>
|
|
311
312
|
readonly onCommitFailure: (conn: Connection.Connection) => Effect.Effect<void, SqlError>
|
|
312
313
|
} => {
|
|
@@ -352,6 +353,7 @@ export const makeSqliteAcquirers = <C extends Connection.Connection>(options: {
|
|
|
352
353
|
|
|
353
354
|
return {
|
|
354
355
|
acquirer: lease,
|
|
356
|
+
borrower: (f) => semaphore.withPermit(Effect.flatMap(available, f)),
|
|
355
357
|
transactionAcquirer: lease,
|
|
356
358
|
onCommitFailure: (conn) => Effect.tapCause(rollback(conn as C), (cause) => Effect.sync(() => poison(cause)))
|
|
357
359
|
}
|