effect 4.0.0-beta.31 → 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/Chunk.d.ts +58 -57
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +20 -21
- package/dist/Chunk.js.map +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +4 -1
- package/dist/Config.js.map +1 -1
- package/dist/Cron.d.ts +3 -6
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +8 -15
- package/dist/Cron.js.map +1 -1
- package/dist/DateTime.d.ts +16 -15
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +8 -8
- package/dist/DateTime.js.map +1 -1
- package/dist/Deferred.d.ts +7 -5
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +7 -5
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +26 -24
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +23 -22
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +3 -4
- package/dist/Effect.js.map +1 -1
- package/dist/Fiber.d.ts +2 -1
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +9 -8
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +8 -7
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +20 -19
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +6 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +17 -16
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +10 -7
- package/dist/FileSystem.js.map +1 -1
- package/dist/Graph.d.ts +64 -64
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +53 -53
- package/dist/Graph.js.map +1 -1
- package/dist/HashMap.d.ts +11 -5
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +3 -1
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +11 -11
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +12 -12
- package/dist/Iterable.js.map +1 -1
- package/dist/Latch.d.ts +69 -3
- package/dist/Latch.d.ts.map +1 -1
- package/dist/Latch.js +58 -0
- package/dist/Latch.js.map +1 -1
- package/dist/Layer.d.ts +84 -0
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +27 -0
- package/dist/Layer.js.map +1 -1
- package/dist/Number.d.ts +74 -18
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +34 -15
- package/dist/Number.js.map +1 -1
- package/dist/Option.d.ts +2 -0
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +183 -0
- package/dist/PartitionedSemaphore.d.ts.map +1 -0
- package/dist/PartitionedSemaphore.js +231 -0
- package/dist/PartitionedSemaphore.js.map +1 -0
- package/dist/PubSub.d.ts +5 -4
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +6 -5
- package/dist/PubSub.js.map +1 -1
- package/dist/Queue.d.ts +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 +30 -0
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +28 -1
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaGetter.js +6 -4
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +32 -27
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Semaphore.d.ts +149 -53
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +137 -117
- package/dist/Semaphore.js.map +1 -1
- package/dist/ServiceMap.d.ts +26 -0
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +36 -21
- package/dist/ServiceMap.js.map +1 -1
- package/dist/Stream.js +1 -1
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +114 -47
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +29 -47
- package/dist/String.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +1 -2
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +81 -115
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/Terminal.d.ts +2 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +5 -4
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +2 -1
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +26 -14
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +8 -4
- package/dist/Trie.js.map +1 -1
- package/dist/TxHashMap.d.ts +77 -59
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +25 -19
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxSemaphore.d.ts +162 -2
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +16 -2
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/index.d.ts +88 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +88 -32
- package/dist/index.js.map +1 -1
- package/dist/internal/dateTime.js +9 -9
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +20 -89
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +2 -1
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/option.js +6 -0
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/trie.js +3 -3
- package/dist/internal/trie.js.map +1 -1
- package/dist/unstable/ai/AiError.js +1 -1
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +2 -2
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/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/Flag.d.ts +2 -2
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +1 -1
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/HelpDoc.d.ts +14 -12
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Param.d.ts +4 -4
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +7 -7
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +1 -1
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +71 -67
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js +9 -2
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
- package/dist/unstable/cli/internal/parser.js +8 -3
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +25 -23
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +3 -2
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +7 -7
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +4 -3
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +3 -2
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +12 -12
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +2 -1
- package/dist/unstable/cluster/Reply.d.ts.map +1 -1
- package/dist/unstable/cluster/Reply.js +4 -3
- package/dist/unstable/cluster/Reply.js.map +1 -1
- package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerServer.js +9 -8
- package/dist/unstable/cluster/RunnerServer.js.map +1 -1
- package/dist/unstable/cluster/Runners.d.ts +2 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +7 -6
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +19 -13
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +5 -4
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +4 -4
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +9 -10
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +2 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.js +1 -4
- package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +5 -4
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +3 -4
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Etag.d.ts.map +1 -1
- package/dist/unstable/http/Etag.js +5 -1
- package/dist/unstable/http/Etag.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +3 -2
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +2 -1
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +2 -1
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +4 -3
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +8 -6
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +2 -1
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +2 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +16 -15
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +3 -2
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +2 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +7 -7
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +2 -2
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +2 -1
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +2 -1
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +3 -2
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +14 -10
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +4 -3
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
- package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/unstable/http/HttpTraceContext.js +27 -15
- package/dist/unstable/http/HttpTraceContext.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +5 -4
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +5 -6
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +4 -2
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +15 -0
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +81 -3
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +2 -2
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +7 -3
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +1 -5
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +4 -2
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js +4 -3
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +4 -4
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +3 -2
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +4 -1
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +3 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts.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/Chunk.ts +68 -63
- package/src/Config.ts +4 -1
- package/src/Cron.ts +10 -15
- package/src/DateTime.ts +16 -15
- package/src/Deferred.ts +8 -6
- package/src/Duration.ts +34 -33
- package/src/Effect.ts +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 +121 -0
- package/src/Number.ts +85 -26
- package/src/Option.ts +2 -0
- package/src/PartitionedSemaphore.ts +414 -0
- package/src/PubSub.ts +7 -6
- package/src/Queue.ts +5 -5
- package/src/Record.ts +52 -47
- package/src/Scheduler.ts +37 -126
- package/src/Schema.ts +49 -1
- package/src/SchemaGetter.ts +4 -4
- package/src/SchemaTransformation.ts +27 -27
- package/src/Semaphore.ts +271 -183
- package/src/ServiceMap.ts +83 -31
- package/src/Stream.ts +1 -1
- package/src/String.ts +122 -69
- package/src/SubscriptionRef.ts +96 -117
- package/src/Terminal.ts +2 -1
- package/src/Tracer.ts +6 -5
- package/src/Trie.ts +26 -14
- package/src/TxHashMap.ts +78 -60
- package/src/TxSemaphore.ts +186 -11
- package/src/index.ts +89 -33
- package/src/internal/dateTime.ts +14 -14
- package/src/internal/effect.ts +29 -121
- package/src/internal/hashMap.ts +4 -3
- package/src/internal/option.ts +7 -0
- package/src/internal/trie.ts +6 -6
- package/src/unstable/ai/AiError.ts +1 -1
- package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
- package/src/unstable/ai/Chat.ts +6 -2
- package/src/unstable/ai/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/Flag.ts +2 -2
- package/src/unstable/cli/HelpDoc.ts +14 -12
- package/src/unstable/cli/Param.ts +15 -11
- package/src/unstable/cli/Primitive.ts +1 -1
- package/src/unstable/cli/Prompt.ts +81 -83
- package/src/unstable/cli/internal/completions/CommandDescriptor.ts +3 -2
- package/src/unstable/cli/internal/parser.ts +7 -4
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +35 -30
- package/src/unstable/cluster/Entity.ts +13 -12
- package/src/unstable/cluster/Message.ts +6 -5
- package/src/unstable/cluster/MessageStorage.ts +26 -25
- package/src/unstable/cluster/Reply.ts +7 -4
- package/src/unstable/cluster/RunnerServer.ts +10 -13
- package/src/unstable/cluster/Runners.ts +8 -7
- package/src/unstable/cluster/Sharding.ts +24 -17
- package/src/unstable/cluster/ShardingConfig.ts +6 -6
- package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
- package/src/unstable/cluster/internal/entityManager.ts +27 -21
- package/src/unstable/devtools/DevToolsSchema.ts +3 -2
- package/src/unstable/http/Cookies.ts +7 -8
- package/src/unstable/http/Etag.ts +5 -3
- package/src/unstable/http/Headers.ts +6 -5
- package/src/unstable/http/HttpClient.ts +2 -1
- package/src/unstable/http/HttpClientRequest.ts +11 -9
- package/src/unstable/http/HttpClientResponse.ts +3 -2
- package/src/unstable/http/HttpIncomingMessage.ts +2 -1
- package/src/unstable/http/HttpMiddleware.ts +16 -15
- package/src/unstable/http/HttpPlatform.ts +3 -2
- package/src/unstable/http/HttpRouter.ts +9 -9
- package/src/unstable/http/HttpServer.ts +3 -9
- package/src/unstable/http/HttpServerError.ts +3 -2
- package/src/unstable/http/HttpServerRequest.ts +25 -21
- package/src/unstable/http/HttpServerResponse.ts +5 -4
- package/src/unstable/http/HttpTraceContext.ts +31 -17
- package/src/unstable/http/UrlParams.ts +11 -14
- package/src/unstable/httpapi/HttpApiBuilder.ts +9 -3
- package/src/unstable/httpapi/HttpApiError.ts +67 -12
- package/src/unstable/observability/OtlpExporter.ts +5 -2
- package/src/unstable/observability/OtlpTracer.ts +8 -4
- package/src/unstable/reactivity/Atom.ts +1 -4
- package/src/unstable/reactivity/AtomRegistry.ts +5 -3
- package/src/unstable/rpc/Rpc.ts +4 -3
- package/src/unstable/rpc/RpcClient.ts +10 -9
- package/src/unstable/rpc/RpcSchema.ts +6 -5
- package/src/unstable/rpc/RpcSerialization.ts +4 -1
- package/src/unstable/rpc/RpcServer.ts +3 -3
- package/src/unstable/socket/Socket.ts +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/src/NullOr.ts +0 -204
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 4.0.0
|
|
3
|
+
*/
|
|
4
|
+
import * as Effect from "./Effect.ts"
|
|
5
|
+
import { dual } from "./Function.ts"
|
|
6
|
+
import * as MutableHashMap from "./MutableHashMap.ts"
|
|
7
|
+
import * as Option from "./Option.ts"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @since 4.0.0
|
|
11
|
+
* @category models
|
|
12
|
+
*/
|
|
13
|
+
export const PartitionedTypeId: PartitionedTypeId = "~effect/PartitionedSemaphore"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @since 4.0.0
|
|
17
|
+
* @category models
|
|
18
|
+
*/
|
|
19
|
+
export type PartitionedTypeId = "~effect/PartitionedSemaphore"
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A `PartitionedSemaphore` controls access to a shared permit pool while
|
|
23
|
+
* tracking waiters by partition key.
|
|
24
|
+
*
|
|
25
|
+
* Waiting permits are distributed across partitions in round-robin order.
|
|
26
|
+
*
|
|
27
|
+
* @since 4.0.0
|
|
28
|
+
* @category models
|
|
29
|
+
*/
|
|
30
|
+
export interface PartitionedSemaphore<in K> {
|
|
31
|
+
readonly [PartitionedTypeId]: PartitionedTypeId
|
|
32
|
+
readonly capacity: number
|
|
33
|
+
readonly available: Effect.Effect<number>
|
|
34
|
+
readonly take: (key: K, permits: number) => Effect.Effect<void>
|
|
35
|
+
readonly release: (permits: number) => Effect.Effect<number>
|
|
36
|
+
readonly withPermits: (
|
|
37
|
+
key: K,
|
|
38
|
+
permits: number
|
|
39
|
+
) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
40
|
+
readonly withPermit: (key: K) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
41
|
+
readonly withPermitsIfAvailable: (
|
|
42
|
+
permits: number
|
|
43
|
+
) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, E, R>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @since 4.0.0
|
|
48
|
+
* @category models
|
|
49
|
+
*/
|
|
50
|
+
export interface Partitioned<in K> extends PartitionedSemaphore<K> {}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Creates a `PartitionedSemaphore` unsafely.
|
|
54
|
+
*
|
|
55
|
+
* @since 4.0.0
|
|
56
|
+
* @category constructors
|
|
57
|
+
*/
|
|
58
|
+
export const makeUnsafe = <K = unknown>(options: {
|
|
59
|
+
readonly permits: number
|
|
60
|
+
}): PartitionedSemaphore<K> => {
|
|
61
|
+
const maxPermits = Math.max(0, options.permits)
|
|
62
|
+
|
|
63
|
+
if (!Number.isFinite(maxPermits)) {
|
|
64
|
+
return {
|
|
65
|
+
[PartitionedTypeId]: PartitionedTypeId,
|
|
66
|
+
capacity: maxPermits,
|
|
67
|
+
available: Effect.succeed(maxPermits),
|
|
68
|
+
take: () => Effect.void,
|
|
69
|
+
release: () => Effect.succeed(maxPermits),
|
|
70
|
+
withPermits: () => (effect) => effect,
|
|
71
|
+
withPermit: () => (effect) => effect,
|
|
72
|
+
withPermitsIfAvailable: () => (effect) => Effect.asSome(effect)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let totalPermits = maxPermits
|
|
77
|
+
let waitingPermits = 0
|
|
78
|
+
|
|
79
|
+
type Waiter = {
|
|
80
|
+
permits: number
|
|
81
|
+
readonly resume: () => void
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const partitions = MutableHashMap.empty<K, Set<Waiter>>()
|
|
85
|
+
let iterator = partitions[Symbol.iterator]()
|
|
86
|
+
|
|
87
|
+
const releaseUnsafe = (permits: number): number => {
|
|
88
|
+
while (permits > 0) {
|
|
89
|
+
if (waitingPermits === 0) {
|
|
90
|
+
totalPermits = Math.min(maxPermits, totalPermits + permits)
|
|
91
|
+
return totalPermits
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let state = iterator.next()
|
|
95
|
+
if (state.done) {
|
|
96
|
+
iterator = partitions[Symbol.iterator]()
|
|
97
|
+
state = iterator.next()
|
|
98
|
+
if (state.done) {
|
|
99
|
+
return totalPermits
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const waiter = state.value[1].values().next().value
|
|
104
|
+
if (waiter === undefined) {
|
|
105
|
+
continue
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
waiter.permits -= 1
|
|
109
|
+
waitingPermits -= 1
|
|
110
|
+
|
|
111
|
+
if (waiter.permits === 0) {
|
|
112
|
+
waiter.resume()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
permits -= 1
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return totalPermits
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const take = (key: K, permits: number): Effect.Effect<void> => {
|
|
122
|
+
if (permits <= 0) {
|
|
123
|
+
return Effect.void
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return Effect.callback<void>((resume) => {
|
|
127
|
+
if (maxPermits < permits) {
|
|
128
|
+
resume(Effect.never)
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (totalPermits >= permits) {
|
|
133
|
+
totalPermits -= permits
|
|
134
|
+
resume(Effect.void)
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const needed = permits - totalPermits
|
|
139
|
+
const taken = permits - needed
|
|
140
|
+
if (totalPermits > 0) {
|
|
141
|
+
totalPermits = 0
|
|
142
|
+
}
|
|
143
|
+
waitingPermits += needed
|
|
144
|
+
|
|
145
|
+
const waiters = Option.getOrElse(
|
|
146
|
+
MutableHashMap.get(partitions, key),
|
|
147
|
+
() => {
|
|
148
|
+
const set = new Set<Waiter>()
|
|
149
|
+
MutableHashMap.set(partitions, key, set)
|
|
150
|
+
return set
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
const entry: Waiter = {
|
|
155
|
+
permits: needed,
|
|
156
|
+
resume: () => {
|
|
157
|
+
cleanup()
|
|
158
|
+
resume(Effect.void)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const cleanup = () => {
|
|
163
|
+
waiters.delete(entry)
|
|
164
|
+
if (waiters.size === 0) {
|
|
165
|
+
MutableHashMap.remove(partitions, key)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
waiters.add(entry)
|
|
170
|
+
|
|
171
|
+
return Effect.sync(() => {
|
|
172
|
+
cleanup()
|
|
173
|
+
waitingPermits -= entry.permits
|
|
174
|
+
if (taken > 0) {
|
|
175
|
+
releaseUnsafe(taken)
|
|
176
|
+
}
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const withPermits =
|
|
182
|
+
(key: K, permits: number) => <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> => {
|
|
183
|
+
if (permits <= 0) {
|
|
184
|
+
return effect
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const takePermits = take(key, permits)
|
|
188
|
+
return Effect.uninterruptibleMask((restore) =>
|
|
189
|
+
Effect.flatMap(
|
|
190
|
+
restore(takePermits),
|
|
191
|
+
() =>
|
|
192
|
+
Effect.ensuring(
|
|
193
|
+
restore(effect),
|
|
194
|
+
Effect.sync(() => {
|
|
195
|
+
releaseUnsafe(permits)
|
|
196
|
+
})
|
|
197
|
+
)
|
|
198
|
+
)
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const tryTake = (permits: number): boolean => {
|
|
203
|
+
if (permits <= 0) {
|
|
204
|
+
return true
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (maxPermits < permits || totalPermits < permits) {
|
|
208
|
+
return false
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
totalPermits -= permits
|
|
212
|
+
return true
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
[PartitionedTypeId]: PartitionedTypeId,
|
|
217
|
+
capacity: maxPermits,
|
|
218
|
+
available: Effect.sync(() => totalPermits),
|
|
219
|
+
take,
|
|
220
|
+
release: (permits) => Effect.sync(() => releaseUnsafe(permits)),
|
|
221
|
+
withPermits,
|
|
222
|
+
withPermit: (key) => withPermits(key, 1),
|
|
223
|
+
withPermitsIfAvailable:
|
|
224
|
+
(permits) => <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<Option.Option<A>, E, R> => {
|
|
225
|
+
if (permits <= 0) {
|
|
226
|
+
return Effect.asSome(effect)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return Effect.suspend(() => {
|
|
230
|
+
if (!tryTake(permits)) {
|
|
231
|
+
return Effect.succeed(Option.none())
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return Effect.ensuring(
|
|
235
|
+
Effect.asSome(effect),
|
|
236
|
+
Effect.sync(() => {
|
|
237
|
+
releaseUnsafe(permits)
|
|
238
|
+
})
|
|
239
|
+
)
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Creates a `PartitionedSemaphore`.
|
|
247
|
+
*
|
|
248
|
+
* @since 4.0.0
|
|
249
|
+
* @category constructors
|
|
250
|
+
*/
|
|
251
|
+
export const make = <K = unknown>(options: {
|
|
252
|
+
readonly permits: number
|
|
253
|
+
}): Effect.Effect<PartitionedSemaphore<K>> => Effect.sync(() => makeUnsafe<K>(options))
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Gets the current number of available permits.
|
|
257
|
+
*
|
|
258
|
+
* @since 4.0.0
|
|
259
|
+
* @category combinators
|
|
260
|
+
*/
|
|
261
|
+
export const available = <K>(self: PartitionedSemaphore<K>): Effect.Effect<number> => self.available
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Gets the total capacity.
|
|
265
|
+
*
|
|
266
|
+
* @since 4.0.0
|
|
267
|
+
* @category getters
|
|
268
|
+
*/
|
|
269
|
+
export const capacity = <K>(self: PartitionedSemaphore<K>): number => self.capacity
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Acquires permits for a partition.
|
|
273
|
+
*
|
|
274
|
+
* @since 4.0.0
|
|
275
|
+
* @category combinators
|
|
276
|
+
*/
|
|
277
|
+
export const take: {
|
|
278
|
+
/**
|
|
279
|
+
* Acquires permits for a partition.
|
|
280
|
+
*
|
|
281
|
+
* @since 4.0.0
|
|
282
|
+
* @category combinators
|
|
283
|
+
*/
|
|
284
|
+
<K>(key: K, permits: number): (self: PartitionedSemaphore<K>) => Effect.Effect<void>
|
|
285
|
+
/**
|
|
286
|
+
* Acquires permits for a partition.
|
|
287
|
+
*
|
|
288
|
+
* @since 4.0.0
|
|
289
|
+
* @category combinators
|
|
290
|
+
*/
|
|
291
|
+
<K>(self: PartitionedSemaphore<K>, key: K, permits: number): Effect.Effect<void>
|
|
292
|
+
} = dual(3, <K>(self: PartitionedSemaphore<K>, key: K, permits: number): Effect.Effect<void> => self.take(key, permits))
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Releases permits back to the shared pool.
|
|
296
|
+
*
|
|
297
|
+
* @since 4.0.0
|
|
298
|
+
* @category combinators
|
|
299
|
+
*/
|
|
300
|
+
export const release: {
|
|
301
|
+
/**
|
|
302
|
+
* Releases permits back to the shared pool.
|
|
303
|
+
*
|
|
304
|
+
* @since 4.0.0
|
|
305
|
+
* @category combinators
|
|
306
|
+
*/
|
|
307
|
+
(permits: number): <K>(self: PartitionedSemaphore<K>) => Effect.Effect<number>
|
|
308
|
+
/**
|
|
309
|
+
* Releases permits back to the shared pool.
|
|
310
|
+
*
|
|
311
|
+
* @since 4.0.0
|
|
312
|
+
* @category combinators
|
|
313
|
+
*/
|
|
314
|
+
<K>(self: PartitionedSemaphore<K>, permits: number): Effect.Effect<number>
|
|
315
|
+
} = dual(2, <K>(self: PartitionedSemaphore<K>, permits: number): Effect.Effect<number> => self.release(permits))
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Runs an effect with permits for a partition.
|
|
319
|
+
*
|
|
320
|
+
* @since 4.0.0
|
|
321
|
+
* @category combinators
|
|
322
|
+
*/
|
|
323
|
+
export const withPermits: {
|
|
324
|
+
/**
|
|
325
|
+
* Runs an effect with permits for a partition.
|
|
326
|
+
*
|
|
327
|
+
* @since 4.0.0
|
|
328
|
+
* @category combinators
|
|
329
|
+
*/
|
|
330
|
+
<K>(self: PartitionedSemaphore<K>, key: K, permits: number): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
331
|
+
/**
|
|
332
|
+
* Runs an effect with permits for a partition.
|
|
333
|
+
*
|
|
334
|
+
* @since 4.0.0
|
|
335
|
+
* @category combinators
|
|
336
|
+
*/
|
|
337
|
+
<K, A, E, R>(
|
|
338
|
+
self: PartitionedSemaphore<K>,
|
|
339
|
+
key: K,
|
|
340
|
+
permits: number,
|
|
341
|
+
effect: Effect.Effect<A, E, R>
|
|
342
|
+
): Effect.Effect<A, E, R>
|
|
343
|
+
} = ((...args: Array<any>) => {
|
|
344
|
+
if (args.length === 3) {
|
|
345
|
+
const [self, key, permits] = args
|
|
346
|
+
return (effect: Effect.Effect<any, any, any>) => self.withPermits(key, permits)(effect)
|
|
347
|
+
}
|
|
348
|
+
const [self, key, permits, effect] = args
|
|
349
|
+
return self.withPermits(key, permits)(effect)
|
|
350
|
+
}) as any
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Runs an effect with a single permit for a partition.
|
|
354
|
+
*
|
|
355
|
+
* @since 4.0.0
|
|
356
|
+
* @category combinators
|
|
357
|
+
*/
|
|
358
|
+
export const withPermit: {
|
|
359
|
+
/**
|
|
360
|
+
* Runs an effect with a single permit for a partition.
|
|
361
|
+
*
|
|
362
|
+
* @since 4.0.0
|
|
363
|
+
* @category combinators
|
|
364
|
+
*/
|
|
365
|
+
<K>(self: PartitionedSemaphore<K>, key: K): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
366
|
+
/**
|
|
367
|
+
* Runs an effect with a single permit for a partition.
|
|
368
|
+
*
|
|
369
|
+
* @since 4.0.0
|
|
370
|
+
* @category combinators
|
|
371
|
+
*/
|
|
372
|
+
<K, A, E, R>(self: PartitionedSemaphore<K>, key: K, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
|
|
373
|
+
} = ((...args: Array<any>) => {
|
|
374
|
+
if (args.length === 2) {
|
|
375
|
+
const [self, key] = args
|
|
376
|
+
return (effect: Effect.Effect<any, any, any>) => self.withPermit(key)(effect)
|
|
377
|
+
}
|
|
378
|
+
const [self, key, effect] = args
|
|
379
|
+
return self.withPermit(key)(effect)
|
|
380
|
+
}) as any
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Runs an effect only if the permits are immediately available.
|
|
384
|
+
*
|
|
385
|
+
* @since 4.0.0
|
|
386
|
+
* @category combinators
|
|
387
|
+
*/
|
|
388
|
+
export const withPermitsIfAvailable: {
|
|
389
|
+
/**
|
|
390
|
+
* Runs an effect only if the permits are immediately available.
|
|
391
|
+
*
|
|
392
|
+
* @since 4.0.0
|
|
393
|
+
* @category combinators
|
|
394
|
+
*/
|
|
395
|
+
<K>(self: PartitionedSemaphore<K>, permits: number): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, E, R>
|
|
396
|
+
/**
|
|
397
|
+
* Runs an effect only if the permits are immediately available.
|
|
398
|
+
*
|
|
399
|
+
* @since 4.0.0
|
|
400
|
+
* @category combinators
|
|
401
|
+
*/
|
|
402
|
+
<K, A, E, R>(
|
|
403
|
+
self: PartitionedSemaphore<K>,
|
|
404
|
+
permits: number,
|
|
405
|
+
effect: Effect.Effect<A, E, R>
|
|
406
|
+
): Effect.Effect<Option.Option<A>, E, R>
|
|
407
|
+
} = ((...args: Array<any>) => {
|
|
408
|
+
if (args.length === 2) {
|
|
409
|
+
const [self, permits] = args
|
|
410
|
+
return (effect: Effect.Effect<any, any, any>) => self.withPermitsIfAvailable(permits)(effect)
|
|
411
|
+
}
|
|
412
|
+
const [self, permits, effect] = args
|
|
413
|
+
return self.withPermitsIfAvailable(permits)(effect)
|
|
414
|
+
}) as any
|
package/src/PubSub.ts
CHANGED
|
@@ -38,6 +38,7 @@ import * as Latch from "./Latch.ts"
|
|
|
38
38
|
import * as MutableList from "./MutableList.ts"
|
|
39
39
|
import * as MutableRef from "./MutableRef.ts"
|
|
40
40
|
import { nextPow2 } from "./Number.ts"
|
|
41
|
+
import * as Option from "./Option.ts"
|
|
41
42
|
import { type Pipeable, pipeArguments } from "./Pipeable.ts"
|
|
42
43
|
import * as Scope from "./Scope.ts"
|
|
43
44
|
import type { Covariant, Invariant } from "./Types.ts"
|
|
@@ -1636,14 +1637,14 @@ export const remaining = <A>(self: Subscription<A>): Effect.Effect<number> =>
|
|
|
1636
1637
|
*
|
|
1637
1638
|
* // Unsafe synchronous check for remaining messages
|
|
1638
1639
|
* const remainingOption = PubSub.remainingUnsafe(subscription)
|
|
1639
|
-
* if (remainingOption) {
|
|
1640
|
-
* console.log("Messages available:", remainingOption)
|
|
1640
|
+
* if (remainingOption._tag === "Some") {
|
|
1641
|
+
* console.log("Messages available:", remainingOption.value)
|
|
1641
1642
|
* } else {
|
|
1642
1643
|
* console.log("Subscription is shutdown")
|
|
1643
1644
|
* }
|
|
1644
1645
|
*
|
|
1645
1646
|
* // Useful for polling or batching scenarios
|
|
1646
|
-
* if (remainingOption && remainingOption > 10) {
|
|
1647
|
+
* if (remainingOption._tag === "Some" && remainingOption.value > 10) {
|
|
1647
1648
|
* // Process messages in batch
|
|
1648
1649
|
* }
|
|
1649
1650
|
* ```
|
|
@@ -1651,11 +1652,11 @@ export const remaining = <A>(self: Subscription<A>): Effect.Effect<number> =>
|
|
|
1651
1652
|
* @since 4.0.0
|
|
1652
1653
|
* @category getters
|
|
1653
1654
|
*/
|
|
1654
|
-
export const remainingUnsafe = <A>(self: Subscription<A>): number
|
|
1655
|
+
export const remainingUnsafe = <A>(self: Subscription<A>): Option.Option<number> => {
|
|
1655
1656
|
if (self.shutdownFlag.current) {
|
|
1656
|
-
return
|
|
1657
|
+
return Option.none()
|
|
1657
1658
|
}
|
|
1658
|
-
return self.subscription.size() + self.replayWindow.remaining
|
|
1659
|
+
return Option.some(self.subscription.size() + self.replayWindow.remaining)
|
|
1659
1660
|
}
|
|
1660
1661
|
|
|
1661
1662
|
// -----------------------------------------------------------------------------
|
package/src/Queue.ts
CHANGED
|
@@ -14,7 +14,7 @@ import * as MutableList from "./MutableList.ts"
|
|
|
14
14
|
import * as Option from "./Option.ts"
|
|
15
15
|
import { hasProperty } from "./Predicate.ts"
|
|
16
16
|
import * as Pull from "./Pull.ts"
|
|
17
|
-
import type {
|
|
17
|
+
import type { SchedulerDispatcher } from "./Scheduler.ts"
|
|
18
18
|
import type * as Types from "./Types.ts"
|
|
19
19
|
|
|
20
20
|
const TypeId = "~effect/Queue"
|
|
@@ -96,7 +96,7 @@ export const asDequeue: <A, E>(self: Queue<A, E>) => Dequeue<A, E> = identity
|
|
|
96
96
|
export interface Enqueue<in A, in E = never> extends Inspectable {
|
|
97
97
|
readonly [EnqueueTypeId]: Enqueue.Variance<A, E>
|
|
98
98
|
readonly strategy: "suspend" | "dropping" | "sliding"
|
|
99
|
-
readonly
|
|
99
|
+
readonly dispatcher: SchedulerDispatcher
|
|
100
100
|
capacity: number
|
|
101
101
|
messages: MutableList.MutableList<any>
|
|
102
102
|
state: Queue.State<any, any>
|
|
@@ -151,7 +151,7 @@ export declare namespace Enqueue {
|
|
|
151
151
|
export interface Dequeue<out A, out E = never> extends Inspectable {
|
|
152
152
|
readonly [DequeueTypeId]: Dequeue.Variance<A, E>
|
|
153
153
|
readonly strategy: "suspend" | "dropping" | "sliding"
|
|
154
|
-
readonly
|
|
154
|
+
readonly dispatcher: SchedulerDispatcher
|
|
155
155
|
capacity: number
|
|
156
156
|
messages: MutableList.MutableList<any>
|
|
157
157
|
state: Queue.State<any, any>
|
|
@@ -341,7 +341,7 @@ export const make = <A, E = never>(
|
|
|
341
341
|
): Effect<Queue<A, E>> =>
|
|
342
342
|
core.withFiber((fiber) => {
|
|
343
343
|
const self = Object.create(QueueProto)
|
|
344
|
-
self.
|
|
344
|
+
self.dispatcher = fiber.currentDispatcher
|
|
345
345
|
self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY
|
|
346
346
|
self.strategy = options?.strategy ?? "suspend"
|
|
347
347
|
self.messages = MutableList.make()
|
|
@@ -1676,7 +1676,7 @@ const scheduleReleaseTaker = <A, E>(self: Enqueue<A, E>) => {
|
|
|
1676
1676
|
return
|
|
1677
1677
|
}
|
|
1678
1678
|
self.scheduleRunning = true
|
|
1679
|
-
self.
|
|
1679
|
+
self.dispatcher.scheduleTask(() => releaseTakers(self), 0)
|
|
1680
1680
|
}
|
|
1681
1681
|
|
|
1682
1682
|
const takeBetweenUnsafe = <A, E>(
|