effect 4.0.0-beta.30 → 4.0.0-beta.32
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/Channel.d.ts +2 -2
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.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 +11 -18
- package/dist/Cron.js.map +1 -1
- package/dist/DateTime.d.ts +49 -92
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +9 -9
- 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 +55 -25
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +100 -70
- package/dist/Duration.js.map +1 -1
- 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 +181 -2
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +35 -2
- 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 +3 -3
- 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 +2346 -114
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +1359 -68
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +2 -2
- package/dist/SchemaAST.js +2 -2
- package/dist/SchemaGetter.js +6 -4
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +2 -2
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.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 +66 -59
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +21 -90
- 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 +3 -4
- 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 +30 -16
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +10 -87
- 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/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/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/Completions.d.ts +16 -0
- package/dist/unstable/cli/Completions.d.ts.map +1 -0
- package/dist/unstable/cli/Completions.js +23 -0
- package/dist/unstable/cli/Completions.js.map +1 -0
- 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/GlobalFlag.d.ts.map +1 -1
- package/dist/unstable/cli/GlobalFlag.js +4 -4
- package/dist/unstable/cli/GlobalFlag.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/index.d.ts +4 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +4 -0
- package/dist/unstable/cli/index.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/DeliverAt.js +1 -1
- package/dist/unstable/cluster/DeliverAt.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/encoding/Ndjson.d.ts +8 -8
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Ndjson.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 +3 -2
- 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 +2 -2
- 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/persistence/Persistable.js +1 -1
- package/dist/unstable/persistence/Persistable.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/RpcGroup.d.ts +1 -3
- package/dist/unstable/rpc/RpcGroup.d.ts.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.map +1 -1
- package/dist/unstable/socket/Socket.js +2 -1
- 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/Channel.ts +3 -3
- package/src/Chunk.ts +68 -63
- package/src/Config.ts +4 -1
- package/src/Cron.ts +13 -18
- package/src/DateTime.ts +51 -92
- package/src/Deferred.ts +8 -6
- package/src/Duration.ts +112 -56
- package/src/Effect.ts +3 -4
- 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 +244 -19
- 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 +5 -5
- package/src/Record.ts +52 -47
- package/src/Scheduler.ts +37 -126
- package/src/Schema.ts +2366 -116
- package/src/SchemaAST.ts +2 -2
- package/src/SchemaGetter.ts +4 -4
- package/src/SchemaRepresentation.ts +2 -2
- 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 +74 -65
- package/src/internal/effect.ts +30 -122
- 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 +17 -15
- package/src/unstable/ai/LanguageModel.ts +148 -97
- package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
- package/src/unstable/ai/Tool.ts +20 -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/Completions.ts +36 -0
- package/src/unstable/cli/Flag.ts +2 -2
- package/src/unstable/cli/GlobalFlag.ts +4 -5
- 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/index.ts +5 -0
- 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/DeliverAt.ts +1 -1
- 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/encoding/Ndjson.ts +17 -17
- 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 +5 -4
- package/src/unstable/http/HttpIncomingMessage.ts +3 -2
- 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 +29 -25
- package/src/unstable/http/HttpServerResponse.ts +7 -6
- package/src/unstable/http/HttpTraceContext.ts +31 -17
- package/src/unstable/http/UrlParams.ts +11 -14
- package/src/unstable/httpapi/HttpApiBuilder.ts +13 -7
- 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/persistence/Persistable.ts +1 -1
- 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/RpcGroup.ts +3 -3
- 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 +2 -1
- 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/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
- package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
- package/dist/unstable/cli/internal/completions/Completions.js +0 -23
- package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
- package/src/NullOr.ts +0 -204
- package/src/unstable/cli/internal/completions/Completions.ts +0 -31
package/src/SchemaAST.ts
CHANGED
|
@@ -2394,9 +2394,9 @@ export function memoizeThunk<A>(f: () => A): () => A {
|
|
|
2394
2394
|
* readonly children: ReadonlyArray<Category>
|
|
2395
2395
|
* }
|
|
2396
2396
|
*
|
|
2397
|
-
* const Category
|
|
2397
|
+
* const Category = Schema.Struct({
|
|
2398
2398
|
* name: Schema.String,
|
|
2399
|
-
* children: Schema.Array(Schema.suspend(() => Category))
|
|
2399
|
+
* children: Schema.Array(Schema.suspend((): Schema.Codec<Category> => Category))
|
|
2400
2400
|
* })
|
|
2401
2401
|
*
|
|
2402
2402
|
* // The recursive branch is a Suspend node
|
package/src/SchemaGetter.ts
CHANGED
|
@@ -1482,10 +1482,10 @@ export function decodeHexString<E extends string>(): Getter<string, E> {
|
|
|
1482
1482
|
*/
|
|
1483
1483
|
export function dateTimeUtcFromInput<E extends DateTime.DateTime.Input>(): Getter<DateTime.Utc, E> {
|
|
1484
1484
|
return transformOrFail((input) => {
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1485
|
+
return Option.match(DateTime.make(input), {
|
|
1486
|
+
onNone: () => Effect.fail(new Issue.InvalidValue(Option.some(input), { message: "Invalid DateTime input" })),
|
|
1487
|
+
onSome: (dt) => Effect.succeed(DateTime.toUtc(dt))
|
|
1488
|
+
})
|
|
1489
1489
|
})
|
|
1490
1490
|
}
|
|
1491
1491
|
|
|
@@ -1646,7 +1646,7 @@ export const fromASTs: (asts: readonly [AST.AST, ...Array<AST.AST>]) => MultiDoc
|
|
|
1646
1646
|
*
|
|
1647
1647
|
* @since 4.0.0
|
|
1648
1648
|
*/
|
|
1649
|
-
export const DocumentFromJson: Schema.Codec<Document,
|
|
1649
|
+
export const DocumentFromJson: Schema.Codec<Document, Schema.Json> = Schema.toCodecJson($Document)
|
|
1650
1650
|
|
|
1651
1651
|
/**
|
|
1652
1652
|
* Schema codec that decodes a {@link MultiDocument} from JSON and encodes it
|
|
@@ -1657,7 +1657,7 @@ export const DocumentFromJson: Schema.Codec<Document, unknown> = Schema.toCodecJ
|
|
|
1657
1657
|
*
|
|
1658
1658
|
* @since 4.0.0
|
|
1659
1659
|
*/
|
|
1660
|
-
export const MultiDocumentFromJson: Schema.Codec<MultiDocument,
|
|
1660
|
+
export const MultiDocumentFromJson: Schema.Codec<MultiDocument, Schema.Json> = Schema.toCodecJson($MultiDocument)
|
|
1661
1661
|
|
|
1662
1662
|
/**
|
|
1663
1663
|
* Wraps a single {@link Document} as a {@link MultiDocument} with one
|
|
@@ -907,15 +907,14 @@ export const bigintFromString = new Transformation(
|
|
|
907
907
|
*/
|
|
908
908
|
export const durationFromNanos: Transformation<Duration.Duration, bigint> = transformOrFail({
|
|
909
909
|
decode: (i) => Effect.succeed(Duration.nanos(i)),
|
|
910
|
-
encode: (a) =>
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
}
|
|
910
|
+
encode: (a) =>
|
|
911
|
+
Option.match(Duration.toNanos(a), {
|
|
912
|
+
onNone: () =>
|
|
913
|
+
Effect.fail(
|
|
914
|
+
new Issue.InvalidValue(Option.some(a), { message: `Unable to encode ${a} into a bigint` })
|
|
915
|
+
),
|
|
916
|
+
onSome: (nanos) => Effect.succeed(nanos)
|
|
917
|
+
})
|
|
919
918
|
})
|
|
920
919
|
|
|
921
920
|
/**
|
|
@@ -1239,9 +1238,9 @@ export const bigDecimalFromString: Transformation<BigDecimal.BigDecimal, string>
|
|
|
1239
1238
|
>({
|
|
1240
1239
|
decode: (s) => {
|
|
1241
1240
|
const result = BigDecimal.fromString(s)
|
|
1242
|
-
return result
|
|
1241
|
+
return Option.isNone(result)
|
|
1243
1242
|
? Effect.fail(new Issue.InvalidValue(Option.some(s), { message: `Invalid BigDecimal string: ${s}` }))
|
|
1244
|
-
: Effect.succeed(result)
|
|
1243
|
+
: Effect.succeed(result.value)
|
|
1245
1244
|
},
|
|
1246
1245
|
encode: (bd) => Effect.succeed(BigDecimal.format(bd))
|
|
1247
1246
|
})
|
|
@@ -1394,10 +1393,10 @@ export const timeZoneNamedFromString: Transformation<DateTime.TimeZone.Named, st
|
|
|
1394
1393
|
string
|
|
1395
1394
|
>({
|
|
1396
1395
|
decode: (s) => {
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1396
|
+
return Option.match(DateTime.zoneMakeNamed(s), {
|
|
1397
|
+
onNone: () => Effect.fail(new Issue.InvalidValue(Option.some(s), { message: `Invalid IANA time zone: ${s}` })),
|
|
1398
|
+
onSome: Effect.succeed
|
|
1399
|
+
})
|
|
1401
1400
|
},
|
|
1402
1401
|
encode: (tz) => Effect.succeed(tz.id)
|
|
1403
1402
|
})
|
|
@@ -1410,10 +1409,10 @@ export const timeZoneFromString: Transformation<DateTime.TimeZone, string> = tra
|
|
|
1410
1409
|
string
|
|
1411
1410
|
>({
|
|
1412
1411
|
decode: (s) => {
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1412
|
+
return Option.match(DateTime.zoneFromString(s), {
|
|
1413
|
+
onNone: () => Effect.fail(new Issue.InvalidValue(Option.some(s), { message: `Invalid time zone: ${s}` })),
|
|
1414
|
+
onSome: Effect.succeed
|
|
1415
|
+
})
|
|
1417
1416
|
},
|
|
1418
1417
|
encode: (tz) => Effect.succeed(DateTime.zoneToString(tz))
|
|
1419
1418
|
})
|
|
@@ -1426,10 +1425,10 @@ export const dateTimeUtcFromString: Transformation<DateTime.Utc, string> = trans
|
|
|
1426
1425
|
string
|
|
1427
1426
|
>({
|
|
1428
1427
|
decode: (s) => {
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1428
|
+
return Option.match(DateTime.make(s), {
|
|
1429
|
+
onNone: () => Effect.fail(new Issue.InvalidValue(Option.some(s), { message: "Invalid DateTime input" })),
|
|
1430
|
+
onSome: (result) => Effect.succeed(DateTime.toUtc(result))
|
|
1431
|
+
})
|
|
1433
1432
|
},
|
|
1434
1433
|
encode: (utc) => Effect.succeed(DateTime.formatIso(utc))
|
|
1435
1434
|
})
|
|
@@ -1442,10 +1441,11 @@ export const dateTimeZonedFromString: Transformation<DateTime.Zoned, string> = t
|
|
|
1442
1441
|
string
|
|
1443
1442
|
>({
|
|
1444
1443
|
decode: (s) => {
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
: Effect.succeed
|
|
1444
|
+
return Option.match(DateTime.makeZonedFromString(s), {
|
|
1445
|
+
onNone: () =>
|
|
1446
|
+
Effect.fail(new Issue.InvalidValue(Option.some(s), { message: `Invalid zoned DateTime string: ${s}` })),
|
|
1447
|
+
onSome: Effect.succeed
|
|
1448
|
+
})
|
|
1449
1449
|
},
|
|
1450
1450
|
encode: (zoned) => Effect.succeed(DateTime.formatIsoZoned(zoned))
|
|
1451
1451
|
})
|
package/src/Semaphore.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 2.0.0
|
|
3
3
|
*/
|
|
4
|
-
import * as Effect from "./Effect.ts"
|
|
4
|
+
import type * as Effect from "./Effect.ts"
|
|
5
|
+
import type { Fiber } from "./Fiber.ts"
|
|
6
|
+
import { dual } from "./Function.ts"
|
|
7
|
+
import * as core from "./internal/core.ts"
|
|
5
8
|
import * as internal from "./internal/effect.ts"
|
|
6
|
-
import * as
|
|
7
|
-
import * as Option from "./Option.ts"
|
|
9
|
+
import type * as Option from "./Option.ts"
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* @category models
|
|
@@ -27,7 +29,7 @@ export interface Semaphore {
|
|
|
27
29
|
/**
|
|
28
30
|
* Adjusts the number of permits available in the semaphore.
|
|
29
31
|
*/
|
|
30
|
-
resize(permits: number): Effect.Effect<void>
|
|
32
|
+
resize(this: Semaphore, permits: number): Effect.Effect<void>
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* Runs an effect with the given number of permits and releases the permits
|
|
@@ -40,7 +42,7 @@ export interface Semaphore {
|
|
|
40
42
|
* If insufficient permits are available, the function will wait until they
|
|
41
43
|
* are released by other tasks.
|
|
42
44
|
*/
|
|
43
|
-
withPermits(permits: number): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
45
|
+
withPermits(this: Semaphore, permits: number): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
48
|
* Runs an effect with the given number of permits and releases the permits
|
|
@@ -53,7 +55,7 @@ export interface Semaphore {
|
|
|
53
55
|
* If insufficient permits are available, the function will wait until they
|
|
54
56
|
* are released by other tasks.
|
|
55
57
|
*/
|
|
56
|
-
withPermit<A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
|
|
58
|
+
withPermit<A, E, R>(this: Semaphore, self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
|
|
57
59
|
|
|
58
60
|
/**
|
|
59
61
|
* Runs an effect only if the specified number of permits are immediately
|
|
@@ -67,6 +69,7 @@ export interface Semaphore {
|
|
|
67
69
|
* the result is `Option.none`.
|
|
68
70
|
*/
|
|
69
71
|
withPermitsIfAvailable(
|
|
72
|
+
this: Semaphore,
|
|
70
73
|
permits: number
|
|
71
74
|
): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, E, R>
|
|
72
75
|
|
|
@@ -75,18 +78,18 @@ export interface Semaphore {
|
|
|
75
78
|
* available permits, suspending the task if they are not yet available.
|
|
76
79
|
* Concurrent pending `take` calls are processed in a first-in, first-out manner.
|
|
77
80
|
*/
|
|
78
|
-
take(permits: number): Effect.Effect<number>
|
|
81
|
+
take(this: Semaphore, permits: number): Effect.Effect<number>
|
|
79
82
|
|
|
80
83
|
/**
|
|
81
84
|
* Releases the specified number of permits and returns the resulting
|
|
82
85
|
* available permits.
|
|
83
86
|
*/
|
|
84
|
-
release(permits: number): Effect.Effect<number>
|
|
87
|
+
release(this: Semaphore, permits: number): Effect.Effect<number>
|
|
85
88
|
|
|
86
89
|
/**
|
|
87
90
|
* Releases all permits held by this semaphore and returns the resulting available permits.
|
|
88
91
|
*/
|
|
89
|
-
releaseAll: Effect.Effect<number>
|
|
92
|
+
readonly releaseAll: Effect.Effect<number>
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
/**
|
|
@@ -126,7 +129,113 @@ export interface Semaphore {
|
|
|
126
129
|
* @since 2.0.0
|
|
127
130
|
* @category constructors
|
|
128
131
|
*/
|
|
129
|
-
export const makeUnsafe
|
|
132
|
+
export const makeUnsafe = (permits: number): Semaphore => new SemaphoreImpl(permits)
|
|
133
|
+
|
|
134
|
+
class SemaphoreImpl implements Semaphore {
|
|
135
|
+
public waiters = new Set<() => void>()
|
|
136
|
+
public taken = 0
|
|
137
|
+
public permits: number
|
|
138
|
+
|
|
139
|
+
constructor(permits: number) {
|
|
140
|
+
this.permits = permits
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
get free() {
|
|
144
|
+
return this.permits - this.taken
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
take(n: number): Effect.Effect<number> {
|
|
148
|
+
const take: Effect.Effect<number> = internal.suspend(() => {
|
|
149
|
+
if (this.free < n) {
|
|
150
|
+
return internal.callback((resume) => {
|
|
151
|
+
if (this.free >= n) return resume(take)
|
|
152
|
+
const observer = () => {
|
|
153
|
+
if (this.free < n) return
|
|
154
|
+
this.waiters.delete(observer)
|
|
155
|
+
resume(take)
|
|
156
|
+
}
|
|
157
|
+
this.waiters.add(observer)
|
|
158
|
+
return internal.sync(() => {
|
|
159
|
+
this.waiters.delete(observer)
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
this.taken += n
|
|
164
|
+
return internal.succeed(n)
|
|
165
|
+
})
|
|
166
|
+
return take
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
updateTakenUnsafe(fiber: Fiber<any, any>, f: (n: number) => number): number {
|
|
170
|
+
this.taken = f(this.taken)
|
|
171
|
+
if (this.waiters.size > 0) {
|
|
172
|
+
fiber.currentDispatcher.scheduleTask(() => {
|
|
173
|
+
const iter = this.waiters.values()
|
|
174
|
+
let item = iter.next()
|
|
175
|
+
while (item.done === false && this.free > 0) {
|
|
176
|
+
item.value()
|
|
177
|
+
item = iter.next()
|
|
178
|
+
}
|
|
179
|
+
}, 0)
|
|
180
|
+
}
|
|
181
|
+
return this.free
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
updateTaken(f: (n: number) => number): Effect.Effect<number> {
|
|
185
|
+
return core.withFiber((fiber) => internal.succeed(this.updateTakenUnsafe(fiber, f)))
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
resize(permits: number) {
|
|
189
|
+
return core.withFiber((fiber) => {
|
|
190
|
+
this.permits = permits
|
|
191
|
+
if (this.free < 0) return internal.void
|
|
192
|
+
this.updateTakenUnsafe(fiber, (taken) => taken)
|
|
193
|
+
return internal.void
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
release(n: number): Effect.Effect<number> {
|
|
198
|
+
return this.updateTaken((taken) => taken - n)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
get releaseAll(): Effect.Effect<number> {
|
|
202
|
+
return this.updateTaken((_) => 0)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
withPermits(n: number) {
|
|
206
|
+
return <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
207
|
+
internal.uninterruptibleMask((restore) =>
|
|
208
|
+
internal.flatMap(
|
|
209
|
+
restore(this.take(n)),
|
|
210
|
+
(permits) =>
|
|
211
|
+
internal.onExitPrimitive(
|
|
212
|
+
restore(self),
|
|
213
|
+
() => {
|
|
214
|
+
this.updateTakenUnsafe(internal.getCurrentFiber()!, (taken) => taken - permits)
|
|
215
|
+
return undefined
|
|
216
|
+
},
|
|
217
|
+
true
|
|
218
|
+
)
|
|
219
|
+
)
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
get withPermit(): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R> {
|
|
224
|
+
return this.withPermits(1)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
withPermitsIfAvailable(n: number) {
|
|
228
|
+
return <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
229
|
+
internal.uninterruptibleMask((restore) => {
|
|
230
|
+
if (this.free < n) return internal.succeedNone
|
|
231
|
+
this.taken += n
|
|
232
|
+
return internal.onExitPrimitive(restore(internal.asSome(self)), () => {
|
|
233
|
+
this.updateTakenUnsafe(internal.getCurrentFiber()!, (taken) => taken - n)
|
|
234
|
+
return undefined
|
|
235
|
+
}, true)
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
}
|
|
130
239
|
|
|
131
240
|
/**
|
|
132
241
|
* Creates a new Semaphore.
|
|
@@ -161,196 +270,175 @@ export const makeUnsafe: (permits: number) => Semaphore = internal.makeSemaphore
|
|
|
161
270
|
* @since 2.0.0
|
|
162
271
|
* @category constructors
|
|
163
272
|
*/
|
|
164
|
-
export const make
|
|
165
|
-
|
|
166
|
-
// -----------------------------------------------------------------------------
|
|
167
|
-
// Partitioned
|
|
168
|
-
// -----------------------------------------------------------------------------
|
|
273
|
+
export const make = (permits: number): Effect.Effect<Semaphore> => internal.sync(() => new SemaphoreImpl(permits))
|
|
169
274
|
|
|
170
275
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
276
|
+
* Adjusts the number of permits available in the semaphore.
|
|
277
|
+
*
|
|
278
|
+
* @since 4.0.0
|
|
279
|
+
* @category combinators
|
|
173
280
|
*/
|
|
174
|
-
export const
|
|
281
|
+
export const resize: {
|
|
282
|
+
/**
|
|
283
|
+
* Adjusts the number of permits available in the semaphore.
|
|
284
|
+
*
|
|
285
|
+
* @since 4.0.0
|
|
286
|
+
* @category combinators
|
|
287
|
+
*/
|
|
288
|
+
(permits: number): (self: Semaphore) => Effect.Effect<void>
|
|
289
|
+
/**
|
|
290
|
+
* Adjusts the number of permits available in the semaphore.
|
|
291
|
+
*
|
|
292
|
+
* @since 4.0.0
|
|
293
|
+
* @category combinators
|
|
294
|
+
*/
|
|
295
|
+
(self: Semaphore, permits: number): Effect.Effect<void>
|
|
296
|
+
} = dual(2, (self: Semaphore, permits: number) => self.resize(permits))
|
|
175
297
|
|
|
176
298
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
299
|
+
* Runs an effect with the given number of permits and releases the permits when
|
|
300
|
+
* the effect completes.
|
|
301
|
+
*
|
|
302
|
+
* @since 4.0.0
|
|
303
|
+
* @category combinators
|
|
179
304
|
*/
|
|
180
|
-
export
|
|
305
|
+
export const withPermits: {
|
|
306
|
+
/**
|
|
307
|
+
* Runs an effect with the given number of permits and releases the permits when
|
|
308
|
+
* the effect completes.
|
|
309
|
+
*
|
|
310
|
+
* @since 4.0.0
|
|
311
|
+
* @category combinators
|
|
312
|
+
*/
|
|
313
|
+
(self: Semaphore, permits: number): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
314
|
+
/**
|
|
315
|
+
* Runs an effect with the given number of permits and releases the permits when
|
|
316
|
+
* the effect completes.
|
|
317
|
+
*
|
|
318
|
+
* @since 4.0.0
|
|
319
|
+
* @category combinators
|
|
320
|
+
*/
|
|
321
|
+
<A, E, R>(self: Semaphore, permits: number, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
|
|
322
|
+
} = ((self: Semaphore, permits: number, effect?: Effect.Effect<any, any, any>) => {
|
|
323
|
+
const withPermits = self.withPermits(permits)
|
|
324
|
+
return effect ? withPermits(effect) : withPermits
|
|
325
|
+
}) as any
|
|
181
326
|
|
|
182
327
|
/**
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* Waiting permits are distributed across partitions in round-robin order.
|
|
187
|
-
*
|
|
188
|
-
* **Previously Known As**
|
|
189
|
-
*
|
|
190
|
-
* This API replaces the following from Effect 3.x:
|
|
191
|
-
*
|
|
192
|
-
* - `PartitionedSemaphore.PartitionedSemaphore`
|
|
328
|
+
* Runs an effect with a single permit and releases the permit when the effect
|
|
329
|
+
* completes.
|
|
193
330
|
*
|
|
194
|
-
* @since
|
|
195
|
-
* @category
|
|
331
|
+
* @since 4.0.0
|
|
332
|
+
* @category combinators
|
|
196
333
|
*/
|
|
197
|
-
export
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
334
|
+
export const withPermit: {
|
|
335
|
+
/**
|
|
336
|
+
* Runs an effect with a single permit and releases the permit when the effect
|
|
337
|
+
* completes.
|
|
338
|
+
*
|
|
339
|
+
* @since 4.0.0
|
|
340
|
+
* @category combinators
|
|
341
|
+
*/
|
|
342
|
+
(self: Semaphore): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
343
|
+
/**
|
|
344
|
+
* Runs an effect with a single permit and releases the permit when the effect
|
|
345
|
+
* completes.
|
|
346
|
+
*
|
|
347
|
+
* @since 4.0.0
|
|
348
|
+
* @category combinators
|
|
349
|
+
*/
|
|
350
|
+
<A, E, R>(self: Semaphore, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
|
|
351
|
+
} = ((self: Semaphore, effect?: Effect.Effect<any, any, any>) => {
|
|
352
|
+
if (!effect) return self.withPermit
|
|
353
|
+
return self.withPermit(effect)
|
|
354
|
+
}) as any
|
|
204
355
|
|
|
205
356
|
/**
|
|
206
|
-
*
|
|
357
|
+
* Runs an effect only if the specified number of permits are immediately
|
|
358
|
+
* available.
|
|
207
359
|
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
* This API replaces the following from Effect 3.x:
|
|
211
|
-
*
|
|
212
|
-
* - `PartitionedSemaphore.makeUnsafe`
|
|
213
|
-
*
|
|
214
|
-
* @since 3.19.4
|
|
215
|
-
* @category constructors
|
|
360
|
+
* @since 4.0.0
|
|
361
|
+
* @category combinators
|
|
216
362
|
*/
|
|
217
|
-
export const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const take = (key: K, permits: number) =>
|
|
239
|
-
Effect.callback<void>((resume) => {
|
|
240
|
-
if (maxPermits < permits) {
|
|
241
|
-
resume(Effect.never)
|
|
242
|
-
return
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (totalPermits >= permits) {
|
|
246
|
-
totalPermits -= permits
|
|
247
|
-
resume(Effect.void)
|
|
248
|
-
return
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const needed = permits - totalPermits
|
|
252
|
-
const taken = permits - needed
|
|
253
|
-
if (totalPermits > 0) {
|
|
254
|
-
totalPermits = 0
|
|
255
|
-
}
|
|
256
|
-
waitingPermits += needed
|
|
257
|
-
|
|
258
|
-
const waiters = Option.getOrElse(
|
|
259
|
-
MutableHashMap.get(partitions, key),
|
|
260
|
-
() => {
|
|
261
|
-
const set = new Set<Waiter>()
|
|
262
|
-
MutableHashMap.set(partitions, key, set)
|
|
263
|
-
return set
|
|
264
|
-
}
|
|
265
|
-
)
|
|
266
|
-
|
|
267
|
-
const entry: Waiter = {
|
|
268
|
-
permits: needed,
|
|
269
|
-
resume: () => {
|
|
270
|
-
cleanup()
|
|
271
|
-
resume(Effect.void)
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
const cleanup = () => {
|
|
276
|
-
waiters.delete(entry)
|
|
277
|
-
if (waiters.size === 0) {
|
|
278
|
-
MutableHashMap.remove(partitions, key)
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
waiters.add(entry)
|
|
283
|
-
|
|
284
|
-
return Effect.sync(() => {
|
|
285
|
-
cleanup()
|
|
286
|
-
waitingPermits -= entry.permits
|
|
287
|
-
if (taken > 0) {
|
|
288
|
-
releaseUnsafe(taken)
|
|
289
|
-
}
|
|
290
|
-
})
|
|
291
|
-
})
|
|
292
|
-
|
|
293
|
-
let iterator = partitions[Symbol.iterator]()
|
|
294
|
-
|
|
295
|
-
const releaseUnsafe = (permits: number): void => {
|
|
296
|
-
while (permits > 0) {
|
|
297
|
-
if (waitingPermits === 0) {
|
|
298
|
-
totalPermits += permits
|
|
299
|
-
return
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
let state = iterator.next()
|
|
303
|
-
if (state.done) {
|
|
304
|
-
iterator = partitions[Symbol.iterator]()
|
|
305
|
-
state = iterator.next()
|
|
306
|
-
if (state.done) {
|
|
307
|
-
return
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const waiter = state.value[1].values().next().value
|
|
312
|
-
if (waiter === undefined) {
|
|
313
|
-
continue
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
waiter.permits -= 1
|
|
317
|
-
waitingPermits -= 1
|
|
318
|
-
|
|
319
|
-
if (waiter.permits === 0) {
|
|
320
|
-
waiter.resume()
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
permits -= 1
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
return {
|
|
328
|
-
[PartitionedTypeId]: PartitionedTypeId,
|
|
329
|
-
withPermits: (key, permits) => {
|
|
330
|
-
const takePermits = take(key, permits)
|
|
331
|
-
return (effect) =>
|
|
332
|
-
Effect.uninterruptibleMask((restore) =>
|
|
333
|
-
Effect.flatMap(
|
|
334
|
-
restore(takePermits),
|
|
335
|
-
() => Effect.ensuring(restore(effect), Effect.sync(() => releaseUnsafe(permits)))
|
|
336
|
-
)
|
|
337
|
-
)
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
363
|
+
export const withPermitsIfAvailable: {
|
|
364
|
+
/**
|
|
365
|
+
* Runs an effect only if the specified number of permits are immediately
|
|
366
|
+
* available.
|
|
367
|
+
*
|
|
368
|
+
* @since 4.0.0
|
|
369
|
+
* @category combinators
|
|
370
|
+
*/
|
|
371
|
+
(self: Semaphore, permits: number): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, E, R>
|
|
372
|
+
/**
|
|
373
|
+
* Runs an effect only if the specified number of permits are immediately
|
|
374
|
+
* available.
|
|
375
|
+
*
|
|
376
|
+
* @since 4.0.0
|
|
377
|
+
* @category combinators
|
|
378
|
+
*/
|
|
379
|
+
<A, E, R>(self: Semaphore, permits: number, effect: Effect.Effect<A, E, R>): Effect.Effect<Option.Option<A>, E, R>
|
|
380
|
+
} = ((self: Semaphore, permits: number, effect?: Effect.Effect<any, any, any>) => {
|
|
381
|
+
const withPermits = self.withPermitsIfAvailable(permits)
|
|
382
|
+
return effect ? withPermits(effect) : withPermits
|
|
383
|
+
}) as any
|
|
341
384
|
|
|
342
385
|
/**
|
|
343
|
-
*
|
|
386
|
+
* Acquires the specified number of permits and returns the resulting available
|
|
387
|
+
* permits, suspending the task if they are not yet available.
|
|
344
388
|
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
|
|
389
|
+
* @since 4.0.0
|
|
390
|
+
* @category combinators
|
|
391
|
+
*/
|
|
392
|
+
export const take: {
|
|
393
|
+
/**
|
|
394
|
+
* Acquires the specified number of permits and returns the resulting available
|
|
395
|
+
* permits, suspending the task if they are not yet available.
|
|
396
|
+
*
|
|
397
|
+
* @since 4.0.0
|
|
398
|
+
* @category combinators
|
|
399
|
+
*/
|
|
400
|
+
(permits: number): (self: Semaphore) => Effect.Effect<number>
|
|
401
|
+
/**
|
|
402
|
+
* Acquires the specified number of permits and returns the resulting available
|
|
403
|
+
* permits, suspending the task if they are not yet available.
|
|
404
|
+
*
|
|
405
|
+
* @since 4.0.0
|
|
406
|
+
* @category combinators
|
|
407
|
+
*/
|
|
408
|
+
(self: Semaphore, permits: number): Effect.Effect<number>
|
|
409
|
+
} = dual(2, (self: Semaphore, permits: number) => self.take(permits))
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Releases the specified number of permits and returns the resulting available
|
|
413
|
+
* permits.
|
|
348
414
|
*
|
|
349
|
-
*
|
|
415
|
+
* @since 4.0.0
|
|
416
|
+
* @category combinators
|
|
417
|
+
*/
|
|
418
|
+
export const release: {
|
|
419
|
+
/**
|
|
420
|
+
* Releases the specified number of permits and returns the resulting available
|
|
421
|
+
* permits.
|
|
422
|
+
*
|
|
423
|
+
* @since 4.0.0
|
|
424
|
+
* @category combinators
|
|
425
|
+
*/
|
|
426
|
+
(permits: number): (self: Semaphore) => Effect.Effect<number>
|
|
427
|
+
/**
|
|
428
|
+
* Releases the specified number of permits and returns the resulting available
|
|
429
|
+
* permits.
|
|
430
|
+
*
|
|
431
|
+
* @since 4.0.0
|
|
432
|
+
* @category combinators
|
|
433
|
+
*/
|
|
434
|
+
(self: Semaphore, permits: number): Effect.Effect<number>
|
|
435
|
+
} = dual(2, (self: Semaphore, permits: number) => self.release(permits))
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Releases all permits held by this semaphore and returns the resulting
|
|
439
|
+
* available permits.
|
|
350
440
|
*
|
|
351
|
-
* @since
|
|
352
|
-
* @category
|
|
441
|
+
* @since 4.0.0
|
|
442
|
+
* @category combinators
|
|
353
443
|
*/
|
|
354
|
-
export const
|
|
355
|
-
readonly permits: number
|
|
356
|
-
}): Effect.Effect<Partitioned<K>> => Effect.sync(() => makePartitionedUnsafe<K>(options))
|
|
444
|
+
export const releaseAll = (self: Semaphore): Effect.Effect<number> => self.releaseAll
|