effect 4.0.0-beta.103 → 4.0.0-beta.104

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.
Files changed (523) hide show
  1. package/dist/Cache.js +1 -1
  2. package/dist/Cache.js.map +1 -1
  3. package/dist/Channel.d.ts +1 -1
  4. package/dist/Channel.d.ts.map +1 -1
  5. package/dist/Channel.js.map +1 -1
  6. package/dist/Config.d.ts.map +1 -1
  7. package/dist/Config.js +28 -7
  8. package/dist/Config.js.map +1 -1
  9. package/dist/ConfigProvider.d.ts.map +1 -1
  10. package/dist/ConfigProvider.js +2 -1
  11. package/dist/ConfigProvider.js.map +1 -1
  12. package/dist/Context.d.ts +2 -2
  13. package/dist/Context.d.ts.map +1 -1
  14. package/dist/Context.js.map +1 -1
  15. package/dist/Crypto.d.ts.map +1 -1
  16. package/dist/Crypto.js +13 -5
  17. package/dist/Crypto.js.map +1 -1
  18. package/dist/Duration.d.ts.map +1 -1
  19. package/dist/Duration.js +12 -1
  20. package/dist/Duration.js.map +1 -1
  21. package/dist/Effect.d.ts +132 -14
  22. package/dist/Effect.d.ts.map +1 -1
  23. package/dist/Effect.js +38 -0
  24. package/dist/Effect.js.map +1 -1
  25. package/dist/Equal.d.ts.map +1 -1
  26. package/dist/Equal.js +10 -2
  27. package/dist/Equal.js.map +1 -1
  28. package/dist/ExecutionPlan.d.ts +73 -0
  29. package/dist/ExecutionPlan.d.ts.map +1 -1
  30. package/dist/ExecutionPlan.js +1 -1
  31. package/dist/ExecutionPlan.js.map +1 -1
  32. package/dist/FiberSet.js +1 -1
  33. package/dist/FileSystem.d.ts +2 -2
  34. package/dist/Function.d.ts +4 -3
  35. package/dist/Function.d.ts.map +1 -1
  36. package/dist/Function.js +5 -5
  37. package/dist/Function.js.map +1 -1
  38. package/dist/Iterable.d.ts.map +1 -1
  39. package/dist/Iterable.js +11 -10
  40. package/dist/Iterable.js.map +1 -1
  41. package/dist/Layer.d.ts.map +1 -1
  42. package/dist/Layer.js +7 -5
  43. package/dist/Layer.js.map +1 -1
  44. package/dist/Schedule.d.ts +8 -8
  45. package/dist/Schedule.d.ts.map +1 -1
  46. package/dist/Schedule.js +4 -4
  47. package/dist/Schedule.js.map +1 -1
  48. package/dist/Schema.d.ts +32 -32
  49. package/dist/Schema.d.ts.map +1 -1
  50. package/dist/Schema.js +23 -18
  51. package/dist/Schema.js.map +1 -1
  52. package/dist/SchemaAST.d.ts +3 -3
  53. package/dist/SchemaAST.d.ts.map +1 -1
  54. package/dist/SchemaAST.js +47 -31
  55. package/dist/SchemaAST.js.map +1 -1
  56. package/dist/SchemaParser.d.ts.map +1 -1
  57. package/dist/SchemaParser.js +35 -53
  58. package/dist/SchemaParser.js.map +1 -1
  59. package/dist/ScopedCache.js +1 -1
  60. package/dist/ScopedCache.js.map +1 -1
  61. package/dist/Sink.d.ts +1 -1
  62. package/dist/Sink.d.ts.map +1 -1
  63. package/dist/Stream.d.ts +27 -4
  64. package/dist/Stream.d.ts.map +1 -1
  65. package/dist/Stream.js +27 -2
  66. package/dist/Stream.js.map +1 -1
  67. package/dist/SynchronizedRef.js +1 -1
  68. package/dist/SynchronizedRef.js.map +1 -1
  69. package/dist/Terminal.js +1 -1
  70. package/dist/Terminal.js.map +1 -1
  71. package/dist/Tuple.d.ts +6 -4
  72. package/dist/Tuple.d.ts.map +1 -1
  73. package/dist/Tuple.js.map +1 -1
  74. package/dist/TxReentrantLock.d.ts +0 -56
  75. package/dist/TxReentrantLock.d.ts.map +1 -1
  76. package/dist/TxReentrantLock.js +8 -8
  77. package/dist/TxReentrantLock.js.map +1 -1
  78. package/dist/internal/dateTime.js +1 -1
  79. package/dist/internal/dateTime.js.map +1 -1
  80. package/dist/internal/executionPlan.js +51 -3
  81. package/dist/internal/executionPlan.js.map +1 -1
  82. package/dist/internal/hashMap.js +12 -8
  83. package/dist/internal/hashMap.js.map +1 -1
  84. package/dist/internal/matcher.js +1 -1
  85. package/dist/internal/matcher.js.map +1 -1
  86. package/dist/internal/schedule.js.map +1 -1
  87. package/dist/internal/schema/annotations.js +2 -0
  88. package/dist/internal/schema/annotations.js.map +1 -1
  89. package/dist/internal/schema/toArbitrary.js +1 -1
  90. package/dist/internal/schema/toArbitrary.js.map +1 -1
  91. package/dist/internal/trie.js +13 -3
  92. package/dist/internal/trie.js.map +1 -1
  93. package/dist/testing/TestClock.d.ts.map +1 -1
  94. package/dist/testing/TestClock.js +11 -1
  95. package/dist/testing/TestClock.js.map +1 -1
  96. package/dist/testing/TestSchema.d.ts +1 -1
  97. package/dist/testing/TestSchema.d.ts.map +1 -1
  98. package/dist/unstable/ai/AiError.js +19 -19
  99. package/dist/unstable/ai/AiError.js.map +1 -1
  100. package/dist/unstable/ai/Chat.js +1 -1
  101. package/dist/unstable/ai/Chat.js.map +1 -1
  102. package/dist/unstable/ai/LanguageModel.js +4 -2
  103. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  104. package/dist/unstable/ai/McpSchema.d.ts +132 -132
  105. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  106. package/dist/unstable/ai/McpSchema.js +8 -8
  107. package/dist/unstable/ai/McpSchema.js.map +1 -1
  108. package/dist/unstable/ai/McpServer.js +1 -1
  109. package/dist/unstable/ai/McpServer.js.map +1 -1
  110. package/dist/unstable/ai/Prompt.d.ts +15 -3
  111. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  112. package/dist/unstable/ai/Prompt.js +6 -3
  113. package/dist/unstable/ai/Prompt.js.map +1 -1
  114. package/dist/unstable/cli/CliError.d.ts +3 -3
  115. package/dist/unstable/cli/CliError.js +11 -11
  116. package/dist/unstable/cli/CliError.js.map +1 -1
  117. package/dist/unstable/cli/Command.d.ts +9 -9
  118. package/dist/unstable/cli/Command.d.ts.map +1 -1
  119. package/dist/unstable/cli/Command.js +8 -6
  120. package/dist/unstable/cli/Command.js.map +1 -1
  121. package/dist/unstable/cli/Param.d.ts +7 -5
  122. package/dist/unstable/cli/Param.d.ts.map +1 -1
  123. package/dist/unstable/cli/Param.js +15 -11
  124. package/dist/unstable/cli/Param.js.map +1 -1
  125. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  126. package/dist/unstable/cli/Primitive.js +31 -24
  127. package/dist/unstable/cli/Primitive.js.map +1 -1
  128. package/dist/unstable/cli/Prompt.d.ts.map +1 -1
  129. package/dist/unstable/cli/Prompt.js +31 -17
  130. package/dist/unstable/cli/Prompt.js.map +1 -1
  131. package/dist/unstable/cli/internal/ansi.js +2 -2
  132. package/dist/unstable/cli/internal/ansi.js.map +1 -1
  133. package/dist/unstable/cli/internal/command.d.ts +2 -2
  134. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  135. package/dist/unstable/cli/internal/command.js +10 -9
  136. package/dist/unstable/cli/internal/command.js.map +1 -1
  137. package/dist/unstable/cli/internal/completions/bash.js +69 -9
  138. package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
  139. package/dist/unstable/cli/internal/completions/descriptor.js +24 -18
  140. package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
  141. package/dist/unstable/cli/internal/completions/fish.js +5 -5
  142. package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
  143. package/dist/unstable/cli/internal/help.d.ts.map +1 -1
  144. package/dist/unstable/cli/internal/help.js +4 -2
  145. package/dist/unstable/cli/internal/help.js.map +1 -1
  146. package/dist/unstable/cli/internal/parser.js +3 -3
  147. package/dist/unstable/cli/internal/parser.js.map +1 -1
  148. package/dist/unstable/cli/internal/wizard.js +2 -2
  149. package/dist/unstable/cli/internal/wizard.js.map +1 -1
  150. package/dist/unstable/cluster/ClusterError.js +7 -7
  151. package/dist/unstable/cluster/ClusterError.js.map +1 -1
  152. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  153. package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
  154. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  155. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  156. package/dist/unstable/cluster/MessageStorage.js +8 -1
  157. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  158. package/dist/unstable/cluster/Reply.d.ts +8 -0
  159. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  160. package/dist/unstable/cluster/Reply.js +12 -0
  161. package/dist/unstable/cluster/Reply.js.map +1 -1
  162. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  163. package/dist/unstable/cluster/RunnerServer.js +4 -2
  164. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  165. package/dist/unstable/cluster/RunnerStorage.d.ts +1 -2
  166. package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
  167. package/dist/unstable/cluster/RunnerStorage.js +7 -6
  168. package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
  169. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  170. package/dist/unstable/cluster/Sharding.js +22 -4
  171. package/dist/unstable/cluster/Sharding.js.map +1 -1
  172. package/dist/unstable/cluster/internal/entityManager.js +1 -1
  173. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  174. package/dist/unstable/cluster/internal/resourceMap.js +2 -2
  175. package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
  176. package/dist/unstable/cluster/internal/resourceRef.js +17 -0
  177. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  178. package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
  179. package/dist/unstable/devtools/DevToolsClient.js +7 -2
  180. package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
  181. package/dist/unstable/encoding/Ini.d.ts +20 -0
  182. package/dist/unstable/encoding/Ini.d.ts.map +1 -0
  183. package/dist/unstable/encoding/Ini.js +153 -0
  184. package/dist/unstable/encoding/Ini.js.map +1 -0
  185. package/dist/unstable/encoding/Msgpack.d.ts +2 -1
  186. package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
  187. package/dist/unstable/encoding/Msgpack.js +21 -7
  188. package/dist/unstable/encoding/Msgpack.js.map +1 -1
  189. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  190. package/dist/unstable/encoding/Ndjson.js +7 -1
  191. package/dist/unstable/encoding/Ndjson.js.map +1 -1
  192. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  193. package/dist/unstable/encoding/Sse.js +14 -23
  194. package/dist/unstable/encoding/Sse.js.map +1 -1
  195. package/dist/unstable/encoding/Toml.d.ts +19 -0
  196. package/dist/unstable/encoding/Toml.d.ts.map +1 -0
  197. package/dist/unstable/encoding/Toml.js +434 -0
  198. package/dist/unstable/encoding/Toml.js.map +1 -0
  199. package/dist/unstable/encoding/Yaml.d.ts +19 -0
  200. package/dist/unstable/encoding/Yaml.d.ts.map +1 -0
  201. package/dist/unstable/encoding/Yaml.js +461 -0
  202. package/dist/unstable/encoding/Yaml.js.map +1 -0
  203. package/dist/unstable/encoding/index.d.ts +12 -0
  204. package/dist/unstable/encoding/index.d.ts.map +1 -1
  205. package/dist/unstable/encoding/index.js +12 -0
  206. package/dist/unstable/encoding/index.js.map +1 -1
  207. package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
  208. package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
  209. package/dist/unstable/eventlog/EventJournal.js +13 -5
  210. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  211. package/dist/unstable/eventlog/EventLogMessage.js +1 -1
  212. package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
  213. package/dist/unstable/eventlog/EventLogServerUnencrypted.js +1 -1
  214. package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
  215. package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
  216. package/dist/unstable/eventlog/SqlEventJournal.js +1 -4
  217. package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
  218. package/dist/unstable/http/FindMyWay/internal/queryString.d.ts +11 -0
  219. package/dist/unstable/http/FindMyWay/internal/queryString.d.ts.map +1 -0
  220. package/dist/unstable/http/FindMyWay/internal/queryString.js +259 -0
  221. package/dist/unstable/http/FindMyWay/internal/queryString.js.map +1 -0
  222. package/dist/unstable/http/FindMyWay/internal/router.d.ts +2 -0
  223. package/dist/unstable/http/FindMyWay/internal/router.d.ts.map +1 -0
  224. package/dist/unstable/http/FindMyWay/internal/router.js +665 -0
  225. package/dist/unstable/http/FindMyWay/internal/router.js.map +1 -0
  226. package/dist/unstable/http/FindMyWay.d.ts +33 -8
  227. package/dist/unstable/http/FindMyWay.d.ts.map +1 -1
  228. package/dist/unstable/http/FindMyWay.js +4 -7
  229. package/dist/unstable/http/FindMyWay.js.map +1 -1
  230. package/dist/unstable/http/HttpClientError.js +1 -1
  231. package/dist/unstable/http/HttpClientError.js.map +1 -1
  232. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  233. package/dist/unstable/http/HttpClientRequest.js +2 -14
  234. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  235. package/dist/unstable/http/HttpClientResponse.js +1 -16
  236. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  237. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  238. package/dist/unstable/http/HttpPlatform.js +21 -3
  239. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  240. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  241. package/dist/unstable/http/HttpServerRequest.js +7 -6
  242. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  243. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  244. package/dist/unstable/http/HttpServerResponse.js +8 -6
  245. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  246. package/dist/unstable/http/Multipart.d.ts +1 -1
  247. package/dist/unstable/http/Multipart.d.ts.map +1 -1
  248. package/dist/unstable/http/Multipart.js +9 -2
  249. package/dist/unstable/http/Multipart.js.map +1 -1
  250. package/dist/unstable/http/MultipartParser/HeadersParser.d.ts +53 -0
  251. package/dist/unstable/http/MultipartParser/HeadersParser.d.ts.map +1 -0
  252. package/dist/unstable/http/MultipartParser/HeadersParser.js +14 -0
  253. package/dist/unstable/http/MultipartParser/HeadersParser.js.map +1 -0
  254. package/dist/unstable/http/MultipartParser/Search.d.ts +11 -0
  255. package/dist/unstable/http/MultipartParser/Search.d.ts.map +1 -0
  256. package/dist/unstable/http/MultipartParser/Search.js +14 -0
  257. package/dist/unstable/http/MultipartParser/Search.js.map +1 -0
  258. package/dist/unstable/http/MultipartParser/internal/contentType.d.ts +5 -0
  259. package/dist/unstable/http/MultipartParser/internal/contentType.d.ts.map +1 -0
  260. package/dist/unstable/http/MultipartParser/internal/contentType.js +82 -0
  261. package/dist/unstable/http/MultipartParser/internal/contentType.js.map +1 -0
  262. package/dist/unstable/http/MultipartParser/internal/headers.d.ts +3 -0
  263. package/dist/unstable/http/MultipartParser/internal/headers.d.ts.map +1 -0
  264. package/dist/unstable/http/MultipartParser/internal/headers.js +194 -0
  265. package/dist/unstable/http/MultipartParser/internal/headers.js.map +1 -0
  266. package/dist/unstable/http/MultipartParser/internal/multipart.d.ts +8 -0
  267. package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -0
  268. package/dist/unstable/http/MultipartParser/internal/multipart.js +226 -0
  269. package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -0
  270. package/dist/unstable/http/MultipartParser/internal/search.d.ts +5 -0
  271. package/dist/unstable/http/MultipartParser/internal/search.d.ts.map +1 -0
  272. package/dist/unstable/http/MultipartParser/internal/search.js +120 -0
  273. package/dist/unstable/http/MultipartParser/internal/search.js.map +1 -0
  274. package/dist/unstable/http/MultipartParser.d.ts +98 -0
  275. package/dist/unstable/http/MultipartParser.d.ts.map +1 -0
  276. package/dist/unstable/http/MultipartParser.js +23 -0
  277. package/dist/unstable/http/MultipartParser.js.map +1 -0
  278. package/dist/unstable/http/Template.d.ts.map +1 -1
  279. package/dist/unstable/http/Template.js +2 -2
  280. package/dist/unstable/http/Template.js.map +1 -1
  281. package/dist/unstable/http/index.d.ts +1 -1
  282. package/dist/unstable/http/index.d.ts.map +1 -1
  283. package/dist/unstable/http/index.js +1 -1
  284. package/dist/unstable/http/index.js.map +1 -1
  285. package/dist/unstable/http/internal/httpBody.d.ts +2 -0
  286. package/dist/unstable/http/internal/httpBody.d.ts.map +1 -0
  287. package/dist/unstable/http/internal/httpBody.js +10 -0
  288. package/dist/unstable/http/internal/httpBody.js.map +1 -0
  289. package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
  290. package/dist/unstable/httpapi/HttpApi.js +5 -5
  291. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  292. package/dist/unstable/httpapi/HttpApiBuilder.js +68 -15
  293. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  294. package/dist/unstable/httpapi/HttpApiClient.d.ts +1 -1
  295. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  296. package/dist/unstable/httpapi/HttpApiClient.js +65 -25
  297. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  298. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +6 -4
  299. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  300. package/dist/unstable/httpapi/HttpApiEndpoint.js +73 -16
  301. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  302. package/dist/unstable/httpapi/HttpApiError.d.ts +5 -5
  303. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  304. package/dist/unstable/httpapi/HttpApiError.js +17 -17
  305. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  306. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +1 -1
  307. package/dist/unstable/httpapi/HttpApiMiddleware.js +1 -1
  308. package/dist/unstable/httpapi/HttpApiSchema.d.ts +219 -0
  309. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  310. package/dist/unstable/httpapi/HttpApiSchema.js +170 -0
  311. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  312. package/dist/unstable/httpapi/OpenApi.d.ts +8 -0
  313. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  314. package/dist/unstable/httpapi/OpenApi.js +45 -18
  315. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  316. package/dist/unstable/observability/OtlpExporter.d.ts +1 -1
  317. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  318. package/dist/unstable/observability/OtlpExporter.js +2 -1
  319. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  320. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  321. package/dist/unstable/observability/OtlpLogger.js +2 -2
  322. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  323. package/dist/unstable/observability/OtlpMetrics.d.ts +2 -2
  324. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  325. package/dist/unstable/observability/OtlpMetrics.js +28 -15
  326. package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
  327. package/dist/unstable/observability/OtlpTracer.js +1 -1
  328. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  329. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  330. package/dist/unstable/persistence/PersistedQueue.js +9 -9
  331. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  332. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  333. package/dist/unstable/persistence/Persistence.js +17 -7
  334. package/dist/unstable/persistence/Persistence.js.map +1 -1
  335. package/dist/unstable/persistence/RateLimiter.d.ts +22 -12
  336. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  337. package/dist/unstable/persistence/RateLimiter.js +15 -42
  338. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  339. package/dist/unstable/persistence/Redis.js +1 -1
  340. package/dist/unstable/persistence/Redis.js.map +1 -1
  341. package/dist/unstable/rpc/RpcClient.d.ts +14 -0
  342. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  343. package/dist/unstable/rpc/RpcClient.js +18 -9
  344. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  345. package/dist/unstable/rpc/RpcClientError.js +2 -2
  346. package/dist/unstable/rpc/RpcClientError.js.map +1 -1
  347. package/dist/unstable/rpc/RpcSerialization.js +3 -1
  348. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  349. package/dist/unstable/schema/Model.d.ts +1 -1
  350. package/dist/unstable/schema/Model.d.ts.map +1 -1
  351. package/dist/unstable/schema/VariantSchema.d.ts +5 -5
  352. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  353. package/dist/unstable/schema/VariantSchema.js +17 -9
  354. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  355. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  356. package/dist/unstable/socket/Socket.js +28 -12
  357. package/dist/unstable/socket/Socket.js.map +1 -1
  358. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  359. package/dist/unstable/sql/SqlClient.js +7 -3
  360. package/dist/unstable/sql/SqlClient.js.map +1 -1
  361. package/dist/unstable/sql/SqlError.js +13 -13
  362. package/dist/unstable/sql/SqlError.js.map +1 -1
  363. package/dist/unstable/sql/SqlResolver.js +8 -6
  364. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  365. package/dist/unstable/sql/Statement.d.ts.map +1 -1
  366. package/dist/unstable/sql/Statement.js +8 -6
  367. package/dist/unstable/sql/Statement.js.map +1 -1
  368. package/dist/unstable/workers/WorkerError.js +5 -5
  369. package/dist/unstable/workers/WorkerError.js.map +1 -1
  370. package/dist/unstable/workflow/WorkflowEngine.d.ts +1 -1
  371. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  372. package/dist/unstable/workflow/WorkflowEngine.js +3 -3
  373. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  374. package/package.json +2 -8
  375. package/src/Cache.ts +1 -1
  376. package/src/Channel.ts +1 -1
  377. package/src/Config.ts +28 -7
  378. package/src/ConfigProvider.ts +4 -1
  379. package/src/Context.ts +5 -5
  380. package/src/Crypto.ts +17 -8
  381. package/src/Duration.ts +16 -2
  382. package/src/Effect.ts +141 -17
  383. package/src/Equal.ts +10 -2
  384. package/src/ExecutionPlan.ts +78 -1
  385. package/src/FiberSet.ts +1 -1
  386. package/src/FileSystem.ts +2 -2
  387. package/src/Function.ts +6 -6
  388. package/src/Iterable.ts +11 -10
  389. package/src/Layer.ts +7 -5
  390. package/src/Schedule.ts +13 -13
  391. package/src/Schema.ts +50 -41
  392. package/src/SchemaAST.ts +69 -37
  393. package/src/SchemaParser.ts +75 -69
  394. package/src/ScopedCache.ts +1 -1
  395. package/src/Sink.ts +1 -1
  396. package/src/Stream.ts +77 -10
  397. package/src/SynchronizedRef.ts +1 -1
  398. package/src/Terminal.ts +1 -1
  399. package/src/Tuple.ts +7 -4
  400. package/src/TxReentrantLock.ts +39 -35
  401. package/src/internal/dateTime.ts +1 -1
  402. package/src/internal/executionPlan.ts +105 -10
  403. package/src/internal/hashMap.ts +20 -14
  404. package/src/internal/matcher.ts +2 -2
  405. package/src/internal/schedule.ts +4 -4
  406. package/src/internal/schema/annotations.ts +3 -0
  407. package/src/internal/schema/toArbitrary.ts +3 -1
  408. package/src/internal/trie.ts +12 -2
  409. package/src/testing/TestClock.ts +13 -1
  410. package/src/testing/TestSchema.ts +1 -1
  411. package/src/unstable/ai/AiError.ts +19 -19
  412. package/src/unstable/ai/Chat.ts +1 -1
  413. package/src/unstable/ai/LanguageModel.ts +4 -2
  414. package/src/unstable/ai/McpSchema.ts +17 -16
  415. package/src/unstable/ai/McpServer.ts +1 -1
  416. package/src/unstable/ai/Prompt.ts +21 -6
  417. package/src/unstable/cli/CliError.ts +12 -12
  418. package/src/unstable/cli/Command.ts +12 -10
  419. package/src/unstable/cli/Param.ts +41 -19
  420. package/src/unstable/cli/Primitive.ts +11 -5
  421. package/src/unstable/cli/Prompt.ts +36 -20
  422. package/src/unstable/cli/internal/ansi.ts +2 -2
  423. package/src/unstable/cli/internal/command.ts +15 -10
  424. package/src/unstable/cli/internal/completions/bash.ts +59 -9
  425. package/src/unstable/cli/internal/completions/descriptor.ts +14 -20
  426. package/src/unstable/cli/internal/completions/fish.ts +5 -7
  427. package/src/unstable/cli/internal/help.ts +4 -2
  428. package/src/unstable/cli/internal/parser.ts +3 -3
  429. package/src/unstable/cli/internal/wizard.ts +2 -2
  430. package/src/unstable/cluster/ClusterError.ts +7 -7
  431. package/src/unstable/cluster/ClusterWorkflowEngine.ts +4 -1
  432. package/src/unstable/cluster/MessageStorage.ts +9 -5
  433. package/src/unstable/cluster/Reply.ts +21 -0
  434. package/src/unstable/cluster/RunnerServer.ts +4 -10
  435. package/src/unstable/cluster/RunnerStorage.ts +9 -7
  436. package/src/unstable/cluster/Sharding.ts +35 -7
  437. package/src/unstable/cluster/internal/entityManager.ts +1 -1
  438. package/src/unstable/cluster/internal/resourceMap.ts +5 -2
  439. package/src/unstable/cluster/internal/resourceRef.ts +27 -5
  440. package/src/unstable/devtools/DevToolsClient.ts +3 -2
  441. package/src/unstable/encoding/Ini.ts +174 -0
  442. package/src/unstable/encoding/Msgpack.ts +47 -28
  443. package/src/unstable/encoding/Ndjson.ts +9 -1
  444. package/src/unstable/encoding/Sse.ts +11 -21
  445. package/src/unstable/encoding/Toml.ts +504 -0
  446. package/src/unstable/encoding/Yaml.ts +541 -0
  447. package/src/unstable/encoding/index.ts +15 -0
  448. package/src/unstable/eventlog/EventJournal.ts +14 -6
  449. package/src/unstable/eventlog/EventLogMessage.ts +1 -1
  450. package/src/unstable/eventlog/EventLogServerUnencrypted.ts +1 -1
  451. package/src/unstable/eventlog/SqlEventJournal.ts +6 -4
  452. package/src/unstable/http/FindMyWay/internal/queryString.ts +420 -0
  453. package/src/unstable/http/FindMyWay/internal/router.ts +950 -0
  454. package/src/unstable/http/FindMyWay.ts +65 -6
  455. package/src/unstable/http/HttpClientError.ts +1 -1
  456. package/src/unstable/http/HttpClientRequest.ts +2 -14
  457. package/src/unstable/http/HttpClientResponse.ts +1 -17
  458. package/src/unstable/http/HttpPlatform.ts +34 -6
  459. package/src/unstable/http/HttpServerRequest.ts +14 -6
  460. package/src/unstable/http/HttpServerResponse.ts +9 -7
  461. package/src/unstable/http/Multipart.ts +9 -2
  462. package/src/unstable/http/MultipartParser/HeadersParser.ts +68 -0
  463. package/src/unstable/http/MultipartParser/Search.ts +17 -0
  464. package/src/unstable/http/MultipartParser/internal/contentType.ts +103 -0
  465. package/src/unstable/http/MultipartParser/internal/headers.ts +615 -0
  466. package/src/unstable/http/MultipartParser/internal/multipart.ts +262 -0
  467. package/src/unstable/http/MultipartParser/internal/search.ts +167 -0
  468. package/src/unstable/http/MultipartParser.ts +115 -0
  469. package/src/unstable/http/Template.ts +6 -5
  470. package/src/unstable/http/index.ts +1 -1
  471. package/src/unstable/http/internal/httpBody.ts +15 -0
  472. package/src/unstable/httpapi/HttpApi.ts +6 -7
  473. package/src/unstable/httpapi/HttpApiBuilder.ts +119 -21
  474. package/src/unstable/httpapi/HttpApiClient.ts +104 -41
  475. package/src/unstable/httpapi/HttpApiEndpoint.ts +117 -29
  476. package/src/unstable/httpapi/HttpApiError.ts +33 -39
  477. package/src/unstable/httpapi/HttpApiMiddleware.ts +1 -1
  478. package/src/unstable/httpapi/HttpApiSchema.ts +353 -0
  479. package/src/unstable/httpapi/OpenApi.ts +70 -20
  480. package/src/unstable/observability/OtlpExporter.ts +4 -2
  481. package/src/unstable/observability/OtlpLogger.ts +3 -1
  482. package/src/unstable/observability/OtlpMetrics.ts +32 -18
  483. package/src/unstable/observability/OtlpTracer.ts +1 -1
  484. package/src/unstable/persistence/PersistedQueue.ts +12 -9
  485. package/src/unstable/persistence/Persistence.ts +27 -7
  486. package/src/unstable/persistence/RateLimiter.ts +54 -31
  487. package/src/unstable/persistence/Redis.ts +1 -1
  488. package/src/unstable/rpc/RpcClient.ts +38 -12
  489. package/src/unstable/rpc/RpcClientError.ts +2 -2
  490. package/src/unstable/rpc/RpcSerialization.ts +1 -1
  491. package/src/unstable/schema/VariantSchema.ts +36 -18
  492. package/src/unstable/socket/Socket.ts +24 -14
  493. package/src/unstable/sql/SqlClient.ts +65 -56
  494. package/src/unstable/sql/SqlError.ts +13 -13
  495. package/src/unstable/sql/SqlResolver.ts +8 -6
  496. package/src/unstable/sql/Statement.ts +13 -8
  497. package/src/unstable/workers/WorkerError.ts +5 -5
  498. package/src/unstable/workflow/WorkflowEngine.ts +8 -3
  499. package/dist/unstable/http/Multipasta/HeadersParser.d.ts +0 -14
  500. package/dist/unstable/http/Multipasta/HeadersParser.d.ts.map +0 -1
  501. package/dist/unstable/http/Multipasta/HeadersParser.js +0 -14
  502. package/dist/unstable/http/Multipasta/HeadersParser.js.map +0 -1
  503. package/dist/unstable/http/Multipasta/Node.d.ts +0 -14
  504. package/dist/unstable/http/Multipasta/Node.d.ts.map +0 -1
  505. package/dist/unstable/http/Multipasta/Node.js +0 -14
  506. package/dist/unstable/http/Multipasta/Node.js.map +0 -1
  507. package/dist/unstable/http/Multipasta/Search.d.ts +0 -14
  508. package/dist/unstable/http/Multipasta/Search.d.ts.map +0 -1
  509. package/dist/unstable/http/Multipasta/Search.js +0 -14
  510. package/dist/unstable/http/Multipasta/Search.js.map +0 -1
  511. package/dist/unstable/http/Multipasta/Web.d.ts +0 -14
  512. package/dist/unstable/http/Multipasta/Web.d.ts.map +0 -1
  513. package/dist/unstable/http/Multipasta/Web.js +0 -14
  514. package/dist/unstable/http/Multipasta/Web.js.map +0 -1
  515. package/dist/unstable/http/Multipasta.d.ts +0 -15
  516. package/dist/unstable/http/Multipasta.d.ts.map +0 -1
  517. package/dist/unstable/http/Multipasta.js +0 -15
  518. package/dist/unstable/http/Multipasta.js.map +0 -1
  519. package/src/unstable/http/Multipasta/HeadersParser.ts +0 -14
  520. package/src/unstable/http/Multipasta/Node.ts +0 -14
  521. package/src/unstable/http/Multipasta/Search.ts +0 -14
  522. package/src/unstable/http/Multipasta/Web.ts +0 -14
  523. package/src/unstable/http/Multipasta.ts +0 -15
@@ -54,7 +54,7 @@ const promptCommand: (
54
54
  ) => Effect.Effect<void, CliError.CliError | Terminal.QuitError, Command.Environment> = Effect.fnUntraced(
55
55
  function*(command, commandLine, sectionName) {
56
56
  const impl = toImpl(command)
57
- const visibleSubcommands = command.subcommands.flatMap((group) => group.commands.filter((child) => !child.hidden))
57
+ const visibleSubcommands = command.subcommands.flatMap((group) => group.commands.filter((child) => !child.unlisted))
58
58
  const config = visibleSubcommands.length === 0 ? impl.config : impl.contextConfig
59
59
 
60
60
  if (config.flags.length > 0) {
@@ -103,7 +103,7 @@ const promptCommand: (
103
103
  )
104
104
 
105
105
  const hasWizardSteps = (command: Command.Command.Any): boolean => {
106
- const hasVisibleSubcommands = command.subcommands.some((group) => group.commands.some((child) => !child.hidden))
106
+ const hasVisibleSubcommands = command.subcommands.some((group) => group.commands.some((child) => !child.unlisted))
107
107
  return hasVisibleSubcommands || toImpl(command).config.orderedParams.length > 0
108
108
  }
109
109
 
@@ -26,7 +26,7 @@ const TypeId = "~effect/cluster/ClusterError"
26
26
  * @since 4.0.0
27
27
  */
28
28
  export class EntityNotAssignedToRunner
29
- extends Schema.ErrorClass<EntityNotAssignedToRunner>(`${TypeId}/EntityNotAssignedToRunner`)({
29
+ extends Schema.Error<EntityNotAssignedToRunner>(`${TypeId}/EntityNotAssignedToRunner`)({
30
30
  _tag: Schema.tag("EntityNotAssignedToRunner"),
31
31
  address: EntityAddress
32
32
  })
@@ -60,7 +60,7 @@ export class EntityNotAssignedToRunner
60
60
  * @category errors
61
61
  * @since 4.0.0
62
62
  */
63
- export class MalformedMessage extends Schema.ErrorClass<MalformedMessage>(`${TypeId}/MalformedMessage`)({
63
+ export class MalformedMessage extends Schema.Error<MalformedMessage>(`${TypeId}/MalformedMessage`)({
64
64
  _tag: Schema.tag("MalformedMessage"),
65
65
  cause: Schema.Defect()
66
66
  }) {
@@ -99,7 +99,7 @@ export class MalformedMessage extends Schema.ErrorClass<MalformedMessage>(`${Typ
99
99
  * @category errors
100
100
  * @since 4.0.0
101
101
  */
102
- export class PersistenceError extends Schema.ErrorClass<PersistenceError>(`${TypeId}/PersistenceError`)({
102
+ export class PersistenceError extends Schema.Error<PersistenceError>(`${TypeId}/PersistenceError`)({
103
103
  _tag: Schema.tag("PersistenceError"),
104
104
  cause: Schema.Defect()
105
105
  }) {
@@ -127,7 +127,7 @@ export class PersistenceError extends Schema.ErrorClass<PersistenceError>(`${Typ
127
127
  * @category errors
128
128
  * @since 4.0.0
129
129
  */
130
- export class RunnerNotRegistered extends Schema.ErrorClass<RunnerNotRegistered>(`${TypeId}/RunnerNotRegistered`)({
130
+ export class RunnerNotRegistered extends Schema.Error<RunnerNotRegistered>(`${TypeId}/RunnerNotRegistered`)({
131
131
  _tag: Schema.tag("RunnerNotRegistered"),
132
132
  address: RunnerAddress
133
133
  }) {
@@ -145,7 +145,7 @@ export class RunnerNotRegistered extends Schema.ErrorClass<RunnerNotRegistered>(
145
145
  * @category errors
146
146
  * @since 4.0.0
147
147
  */
148
- export class RunnerUnavailable extends Schema.ErrorClass<RunnerUnavailable>(`${TypeId}/RunnerUnavailable`)({
148
+ export class RunnerUnavailable extends Schema.Error<RunnerUnavailable>(`${TypeId}/RunnerUnavailable`)({
149
149
  _tag: Schema.tag("RunnerUnavailable"),
150
150
  address: RunnerAddress
151
151
  }) {
@@ -181,7 +181,7 @@ export class RunnerUnavailable extends Schema.ErrorClass<RunnerUnavailable>(`${T
181
181
  * @category errors
182
182
  * @since 4.0.0
183
183
  */
184
- export class MailboxFull extends Schema.ErrorClass<MailboxFull>(`${TypeId}/MailboxFull`)({
184
+ export class MailboxFull extends Schema.Error<MailboxFull>(`${TypeId}/MailboxFull`)({
185
185
  _tag: Schema.tag("MailboxFull"),
186
186
  address: EntityAddress
187
187
  }) {
@@ -214,7 +214,7 @@ export class MailboxFull extends Schema.ErrorClass<MailboxFull>(`${TypeId}/Mailb
214
214
  * @since 4.0.0
215
215
  */
216
216
  export class AlreadyProcessingMessage
217
- extends Schema.ErrorClass<AlreadyProcessingMessage>(`${TypeId}/AlreadyProcessingMessage`)({
217
+ extends Schema.Error<AlreadyProcessingMessage>(`${TypeId}/AlreadyProcessingMessage`)({
218
218
  _tag: Schema.tag("AlreadyProcessingMessage"),
219
219
  envelopeId: SnowflakeFromString,
220
220
  address: EntityAddress
@@ -618,7 +618,10 @@ export const make = Effect.gen(function*() {
618
618
  payload: {
619
619
  name: options.clock.name,
620
620
  workflowName: workflow._tag,
621
- wakeUp: DateTime.addDuration(now, options.clock.duration)
621
+ wakeUp: DateTime.mapEpochMillis(
622
+ DateTime.addDuration(now, options.clock.duration),
623
+ Math.ceil
624
+ )
622
625
  }
623
626
  })
624
627
  ),
@@ -606,11 +606,7 @@ export const makeEncoded: (encoded: Encoded) => Effect.Effect<
606
606
  ),
607
607
  Effect.asVoid
608
608
  ),
609
- saveReply: (reply) =>
610
- Effect.flatMap(
611
- Reply.serialize(reply),
612
- encoded.saveReply
613
- ),
609
+ saveReply: (reply) => Effect.flatMap(Reply.serializeOrDefect(reply), encoded.saveReply),
614
610
  clearReplies: encoded.clearReplies,
615
611
  repliesFor: Effect.fnUntraced(function*(messages) {
616
612
  const requestIds = Arr.empty<string>()
@@ -995,6 +991,14 @@ export class MemoryDriver extends Context.Service<MemoryDriver>()("effect/cluste
995
991
  resetAddress: () => Effect.void,
996
992
  clearAddress: (address) =>
997
993
  Effect.sync(() => {
994
+ for (const [primaryKey, entry] of requestsByPrimaryKey) {
995
+ const envelope = entry.envelope
996
+ const sameAddress = address.entityType === envelope.address.entityType &&
997
+ address.entityId === envelope.address.entityId
998
+ if (sameAddress) {
999
+ requestsByPrimaryKey.delete(primaryKey)
1000
+ }
1001
+ }
998
1002
  for (let i = journal.length - 1; i >= 0; i--) {
999
1003
  const envelope = journal[i]
1000
1004
  const sameAddress = address.entityType === envelope.address.entityType &&
@@ -433,6 +433,27 @@ export const serialize = <R extends Rpc.Any>(
433
433
  )
434
434
  }
435
435
 
436
+ /**
437
+ * Serializes a `ReplyWithContext`, falling back to a serializable defect reply
438
+ * when the original reply cannot be encoded.
439
+ *
440
+ * @category serialization
441
+ * @since 4.0.0
442
+ */
443
+ export const serializeOrDefect = <R extends Rpc.Any>(
444
+ self: ReplyWithContext<R>
445
+ ): Effect.Effect<Encoded> =>
446
+ Effect.catchTag(
447
+ serialize(self),
448
+ "MalformedMessage",
449
+ (error) =>
450
+ Effect.orDie(serialize(ReplyWithContext.fromDefect({
451
+ id: self.reply.id,
452
+ requestId: self.reply.requestId,
453
+ defect: error
454
+ })))
455
+ )
456
+
436
457
  /**
437
458
  * Serializes an outgoing request's last received reply when one exists, returning
438
459
  * `None` when no reply has been received and refailing encoding errors as
@@ -42,15 +42,6 @@ const serializeDefectReply = <R extends Rpc.Any>(
42
42
  defect
43
43
  })))
44
44
 
45
- const serializeReply = <R extends Rpc.Any>(
46
- reply: Reply.ReplyWithContext<R>
47
- ): Effect.Effect<Reply.Encoded> =>
48
- Effect.catchTag(
49
- Reply.serialize(reply),
50
- "MalformedMessage",
51
- (error) => serializeDefectReply(reply, error)
52
- )
53
-
54
45
  /**
55
46
  * Layer that handles runner protocol RPCs by forwarding requests to `Sharding`
56
47
  * and `MessageStorage`.
@@ -84,7 +75,7 @@ export const layerHandlers = Runners.Rpcs.toLayer(Effect.gen(function*() {
84
75
  envelope: request,
85
76
  lastSentReply: Option.none(),
86
77
  respond(reply) {
87
- resume(serializeReply(reply))
78
+ resume(Reply.serializeOrDefect(reply))
88
79
  return Effect.void
89
80
  }
90
81
  })
@@ -138,6 +129,9 @@ export const layerHandlers = Runners.Rpcs.toLayer(Effect.gen(function*() {
138
129
  return Reply.serialize(reply).pipe(
139
130
  Effect.flatMap((reply) => {
140
131
  Queue.offerUnsafe(queue, reply)
132
+ if (reply._tag === "WithExit") {
133
+ Queue.endUnsafe(queue)
134
+ }
141
135
  return Effect.void
142
136
  }),
143
137
  Effect.catchTag("MalformedMessage", (error) =>
@@ -195,29 +195,31 @@ export const makeEncoded = (encoded: Encoded) =>
195
195
  *
196
196
  * **Details**
197
197
  *
198
- * Registered runners are treated as healthy and shard acquisition is kept only in
199
- * process memory.
198
+ * Runner health and shard acquisition are kept only in process memory.
200
199
  *
201
200
  * @category constructors
202
201
  * @since 4.0.0
203
202
  */
204
203
  export const makeMemory = Effect.gen(function*() {
205
- const runners = MutableHashMap.empty<RunnerAddress, Runner>()
204
+ const runners = MutableHashMap.empty<RunnerAddress, readonly [runner: Runner, healthy: boolean]>()
206
205
  let acquired: Array<ShardId.ShardId> = []
207
206
  let id = 0
208
207
 
209
208
  return RunnerStorage.of({
210
- getRunners: Effect.sync(() => Array.from(MutableHashMap.values(runners), (runner) => [runner, true])),
211
- register: (runner) =>
209
+ getRunners: Effect.sync(() => Array.from(MutableHashMap.values(runners))),
210
+ register: (runner, healthy) =>
212
211
  Effect.sync(() => {
213
- MutableHashMap.set(runners, runner.address, runner)
212
+ MutableHashMap.set(runners, runner.address, [runner, healthy])
214
213
  return MachineId.make(id++)
215
214
  }),
216
215
  unregister: (address) =>
217
216
  Effect.sync(() => {
218
217
  MutableHashMap.remove(runners, address)
219
218
  }),
220
- setRunnerHealth: () => Effect.void,
219
+ setRunnerHealth: (address, healthy) =>
220
+ Effect.sync(() => {
221
+ MutableHashMap.modify(runners, address, ([runner]) => [runner, healthy] as const)
222
+ }),
221
223
  acquire: (_address, shardIds) => {
222
224
  acquired = Array.from(shardIds)
223
225
  return Effect.succeed(acquired)
@@ -240,6 +240,8 @@ const make = Effect.gen(function*() {
240
240
  const runnerStorage = yield* RunnerStorage
241
241
 
242
242
  const entityManagers = new Map<string, EntityManagerState>()
243
+ let entityRegistrationStartMillis: number | undefined
244
+ let entityRegistrationFallbackStartMillis: number | undefined
243
245
 
244
246
  const shardAssignments = MutableHashMap.empty<ShardId, RunnerAddress>()
245
247
  const selfShards = MutableHashSet.empty<ShardId>()
@@ -591,7 +593,6 @@ const make = Effect.gen(function*() {
591
593
  const entityRegistrationTimeoutMillis = Duration.toMillis(
592
594
  Duration.fromInputUnsafe(config.entityRegistrationTimeout)
593
595
  )
594
- const storageStartMillis = clock.currentTimeMillisUnsafe()
595
596
 
596
597
  yield* Effect.gen(function*() {
597
598
  yield* Effect.logDebug("Starting")
@@ -617,8 +618,15 @@ const make = Effect.gen(function*() {
617
618
  }
618
619
  const state = entityManagers.get(address.entityType)
619
620
  if (!state) {
620
- const sinceStart = clock.currentTimeMillisUnsafe() - storageStartMillis
621
- if (sinceStart < entityRegistrationTimeoutMillis) {
621
+ const now = clock.currentTimeMillisUnsafe()
622
+ const registrationStarted = entityRegistrationStartMillis !== undefined
623
+ const timeoutStartMillis = entityRegistrationStartMillis ??
624
+ (entityRegistrationFallbackStartMillis ??= now)
625
+ // If registration never starts, allow two intervals from the first missing read before failing.
626
+ const timeoutMillis = registrationStarted
627
+ ? entityRegistrationTimeoutMillis
628
+ : entityRegistrationTimeoutMillis * 2
629
+ if (now - timeoutStartMillis < timeoutMillis) {
622
630
  // reset address in the case that the entity is slow to register
623
631
  MutableHashSet.add(resetAddresses, address)
624
632
  return Effect.void
@@ -961,13 +969,13 @@ const make = Effect.gen(function*() {
961
969
  void,
962
970
  MailboxFull | AlreadyProcessingMessage | PersistenceError
963
971
  > {
972
+ const isPersisted = Context.get(
973
+ message._tag === "OutgoingRequest" ? message.annotations : message.rpc.annotations,
974
+ Persisted
975
+ )
964
976
  return Effect.catchFilter(
965
977
  Effect.suspend(() => {
966
978
  const address = message.envelope.address
967
- const isPersisted = Context.get(
968
- message._tag === "OutgoingRequest" ? message.annotations : message.rpc.annotations,
969
- Persisted
970
- )
971
979
  if (isPersisted && !storageEnabled) {
972
980
  return Effect.die("Sharding.sendOutgoing: Persisted messages require MessageStorage")
973
981
  }
@@ -989,6 +997,25 @@ const make = Effect.gen(function*() {
989
997
  ? Result.succeed(error)
990
998
  : Result.fail(error),
991
999
  (error) => {
1000
+ // Abandon the message during teardown: retrying would loop forever once the runner is shutting down
1001
+ if (error._tag === "EntityNotAssignedToRunner") {
1002
+ const targetManager = entityManagers.get(message.envelope.address.entityType)
1003
+ const cannotRecover = MutableRef.get(isShutdown) ||
1004
+ (targetManager !== undefined && targetManager.status !== "alive")
1005
+ if (cannotRecover) {
1006
+ if (!isPersisted) {
1007
+ return Effect.logDebug("Abandoning outgoing message during shutdown", message.envelope.address)
1008
+ }
1009
+ const persist = message._tag === "OutgoingRequest"
1010
+ ? storage.saveRequest(message)
1011
+ : storage.saveEnvelope(message)
1012
+ return Effect.catchTag(persist, "MalformedMessage", Effect.die).pipe(
1013
+ Effect.andThen(
1014
+ Effect.logWarning("Persisting outgoing message abandoned during shutdown", message.envelope.address)
1015
+ )
1016
+ )
1017
+ }
1018
+ }
992
1019
  if (retries === 0) {
993
1020
  return Effect.die(error)
994
1021
  }
@@ -1461,6 +1488,7 @@ const make = Effect.gen(function*() {
1461
1488
  // register entities while storage is idle
1462
1489
  // this ensures message order is preserved
1463
1490
  yield* withStorageReadLock(Effect.sync(() => {
1491
+ entityRegistrationStartMillis ??= clock.currentTimeMillisUnsafe()
1464
1492
  entityManagers.set(entity.type, state)
1465
1493
  if (entityManagerLatches.has(entity.type)) {
1466
1494
  entityManagerLatches.get(entity.type)!.openUnsafe()
@@ -110,7 +110,7 @@ export const make = Effect.fnUntraced(function*<
110
110
  const clock = yield* Clock
111
111
  const context = yield* Effect.context<Rpc.Services<Rpcs> | Rpc.Middleware<Rpcs> | RX>()
112
112
  const defectRetryPolicy = options.defectRetryPolicy
113
- ? Schedule.andThen(options.defectRetryPolicy, defaultRetryPolicy)
113
+ ? Schedule.concat(options.defectRetryPolicy, defaultRetryPolicy)
114
114
  : defaultRetryPolicy
115
115
  const retryDriver = yield* Schedule.toStepWithSleep(defectRetryPolicy)
116
116
  const entityRpcs = new Map(entity.protocol.requests)
@@ -65,7 +65,7 @@ export class ResourceMap<K, A, E> {
65
65
  if (existing) {
66
66
  return Deferred.await(existing.deferred)
67
67
  }
68
- const scope = Effect.runSync(Scope.make())
68
+ const scope = Scope.makeUnsafe()
69
69
  const deferred = Deferred.makeUnsafe<A, E>()
70
70
  backingSet(this.entries, key, { scope, deferred })
71
71
  return Effect.onExit(this.lookup(key, scope), (exit) => {
@@ -73,7 +73,10 @@ export class ResourceMap<K, A, E> {
73
73
  return Deferred.done(deferred, exit)
74
74
  }
75
75
  backingDelete(this.entries, key)
76
- return Deferred.done(deferred, exit)
76
+ return Effect.andThen(
77
+ Deferred.done(deferred, exit),
78
+ Scope.close(scope, exit)
79
+ )
77
80
  })
78
81
  })
79
82
  }
@@ -1,3 +1,4 @@
1
+ import type * as Cause from "../../../Cause.ts"
1
2
  import * as Effect from "../../../Effect.ts"
2
3
  import * as Exit from "../../../Exit.ts"
3
4
  import * as Latch from "../../../Latch.ts"
@@ -7,7 +8,7 @@ import * as Scope from "../../../Scope.ts"
7
8
  import { internalInterruptors } from "./interruptors.ts"
8
9
 
9
10
  /** @internal */
10
- export type State<A> = {
11
+ export type State<A, E> = {
11
12
  readonly _tag: "Closed"
12
13
  } | {
13
14
  readonly _tag: "Acquiring"
@@ -16,6 +17,10 @@ export type State<A> = {
16
17
  readonly _tag: "Acquired"
17
18
  readonly scope: Scope.Closeable
18
19
  readonly value: A
20
+ } | {
21
+ readonly _tag: "Failed"
22
+ readonly scope: Scope.Closeable
23
+ readonly cause: Cause.Cause<E>
19
24
  }
20
25
 
21
26
  /** @internal */
@@ -24,7 +29,7 @@ export class ResourceRef<A, E = never> {
24
29
  parentScope: Scope.Scope,
25
30
  acquire: (scope: Scope.Scope) => Effect.Effect<A, E>
26
31
  ) {
27
- const state = MutableRef.make<State<A>>({ _tag: "Closed" })
32
+ const state = MutableRef.make<State<A, E>>({ _tag: "Closed" })
28
33
 
29
34
  yield* Scope.addFinalizerExit(parentScope, (exit) => {
30
35
  const s = MutableRef.get(state)
@@ -44,10 +49,10 @@ export class ResourceRef<A, E = never> {
44
49
  return new ResourceRef(state, acquire)
45
50
  })
46
51
 
47
- readonly state: MutableRef.MutableRef<State<A>>
52
+ readonly state: MutableRef.MutableRef<State<A, E>>
48
53
  readonly acquire: (scope: Scope.Scope) => Effect.Effect<A, E>
49
54
  constructor(
50
- state: MutableRef.MutableRef<State<A>>,
55
+ state: MutableRef.MutableRef<State<A, E>>,
51
56
  acquire: (scope: Scope.Scope) => Effect.Effect<A, E>
52
57
  ) {
53
58
  this.state = state
@@ -84,15 +89,32 @@ export class ResourceRef<A, E = never> {
84
89
  MutableRef.set(this.state, { _tag: "Acquired", scope, value })
85
90
  return this.latch.open
86
91
  })
92
+ ).pipe(
93
+ Effect.onExit((exit) => {
94
+ if (Exit.isSuccess(exit)) {
95
+ return Effect.void
96
+ }
97
+ return Scope.close(scope, exit).pipe(
98
+ Effect.ensuring(Effect.sync(() => {
99
+ const state = this.state.current
100
+ if (state._tag === "Acquiring" && state.scope === scope) {
101
+ MutableRef.set(this.state, { _tag: "Failed", scope, cause: exit.cause })
102
+ this.latch.openUnsafe()
103
+ }
104
+ }))
105
+ )
106
+ })
87
107
  )
88
108
  }
89
109
 
90
- await: Effect.Effect<A> = Effect.suspend(() => {
110
+ await: Effect.Effect<A, E> = Effect.suspend(() => {
91
111
  const s = this.state.current
92
112
  if (s._tag === "Closed") {
93
113
  return Effect.interrupt
94
114
  } else if (s._tag === "Acquired") {
95
115
  return Effect.succeed(s.value)
116
+ } else if (s._tag === "Failed") {
117
+ return Effect.failCause(s.cause)
96
118
  }
97
119
  return Effect.flatMap(this.latch.await, () => this.await)
98
120
  })
@@ -184,7 +184,8 @@ const makeTracerEffect = Effect.gen(function*() {
184
184
  return Tracer.make({
185
185
  span(options) {
186
186
  const span = currentTracer.span(options)
187
- client.sendUnsafe(span)
187
+ // the span is mutated in place, so send a snapshot of its current state
188
+ client.sendUnsafe({ ...span })
188
189
  const oldEvent = span.event
189
190
  span.event = function(this: Tracer.Span, name, startTime, attributes) {
190
191
  client.sendUnsafe({
@@ -201,7 +202,7 @@ const makeTracerEffect = Effect.gen(function*() {
201
202
  const oldEnd = span.end
202
203
  span.end = function(this: Tracer.Span, endTime, exit) {
203
204
  oldEnd.call(this, endTime, exit)
204
- client.sendUnsafe(span)
205
+ client.sendUnsafe({ ...span })
205
206
  }
206
207
 
207
208
  return span
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Parses INI configuration files.
3
+ *
4
+ * This module contains the decoding surface used by Effect's CLI without
5
+ * pulling in the complete `ini` package.
6
+ *
7
+ * @since 4.0.0
8
+ */
9
+
10
+ /*
11
+ * The parser is adapted from `ini` 7.0.0.
12
+ *
13
+ * Copyright (c) Isaac Z. Schlueter and Contributors
14
+ *
15
+ * Permission to use, copy, modify, and/or distribute this software for any
16
+ * purpose with or without fee is hereby granted, provided that the above
17
+ * copyright notice and this permission notice appear in all copies.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
20
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
21
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
23
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
24
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
25
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26
+ */
27
+
28
+ const hasOwn = Object.prototype.hasOwnProperty
29
+
30
+ const splitSections = (value: string): Array<string> => {
31
+ const sections: Array<string> = []
32
+ let start = 0
33
+ let index = 0
34
+ while ((index = value.indexOf(".", index)) !== -1) {
35
+ if (index === 0 || value[index - 1] !== "\\") {
36
+ sections.push(value.slice(start, index))
37
+ start = index + 1
38
+ }
39
+ index++
40
+ }
41
+ sections.push(value.slice(start))
42
+ return sections
43
+ }
44
+
45
+ const isQuoted = (value: string): boolean =>
46
+ value.length >= 2 &&
47
+ ((value.startsWith("\"") && value.endsWith("\"")) ||
48
+ (value.startsWith("'") && value.endsWith("'")))
49
+
50
+ const unquote = (input: string | undefined): string => {
51
+ let value = (input ?? "").trim()
52
+ if (isQuoted(value)) {
53
+ if (value[0] === "'") {
54
+ value = value.slice(1, -1)
55
+ }
56
+ try {
57
+ return JSON.parse(value)
58
+ } catch {
59
+ return value
60
+ }
61
+ }
62
+
63
+ let escaped = false
64
+ let output = ""
65
+ for (const character of value) {
66
+ if (escaped) {
67
+ output += character === ";" || character === "#" || character === "\\"
68
+ ? character
69
+ : `\\${character}`
70
+ escaped = false
71
+ } else if (character === ";" || character === "#") {
72
+ break
73
+ } else if (character === "\\") {
74
+ escaped = true
75
+ } else {
76
+ output += character
77
+ }
78
+ }
79
+ return output.trim()
80
+ }
81
+
82
+ /**
83
+ * Parses an INI document into a null-prototype record.
84
+ *
85
+ * Section names separated by dots become nested records, repeated keys ending
86
+ * in `[]` become arrays, and the scalar values `true`, `false`, and `null` are
87
+ * decoded. Other scalar values remain strings.
88
+ *
89
+ * @category decoding
90
+ * @since 4.0.0
91
+ */
92
+ export const parse = (input: string): Record<string, unknown> => {
93
+ const output: Record<string, any> = Object.create(null)
94
+ let current = output
95
+ const sectionPattern = /^\[([^\]]*)\]\s*$/
96
+ const propertyPattern = /^([^=]+)(=(.*))?$/
97
+
98
+ for (const line of input.split(/[\r\n]+/g)) {
99
+ if (line.length === 0 || /^\s*(?:[;#]|$)/.test(line)) {
100
+ continue
101
+ }
102
+
103
+ const sectionMatch = sectionPattern.exec(line)
104
+ if (sectionMatch !== null) {
105
+ const section = unquote(sectionMatch[1])
106
+ if (section === "__proto__") {
107
+ current = Object.create(null)
108
+ } else {
109
+ current = output[section] ??= Object.create(null)
110
+ }
111
+ continue
112
+ }
113
+
114
+ const propertyMatch = propertyPattern.exec(line)
115
+ if (propertyMatch === null) {
116
+ continue
117
+ }
118
+
119
+ const rawKey = unquote(propertyMatch[1])
120
+ const array = rawKey.length > 2 && rawKey.endsWith("[]")
121
+ const key = array ? rawKey.slice(0, -2) : rawKey
122
+ if (key === "__proto__") {
123
+ continue
124
+ }
125
+
126
+ const rawValue = propertyMatch[2] === undefined ? true : unquote(propertyMatch[3])
127
+ const value = rawValue === "true" || rawValue === "false" || rawValue === "null"
128
+ ? JSON.parse(rawValue)
129
+ : rawValue
130
+
131
+ if (array) {
132
+ if (!hasOwn.call(current, key)) {
133
+ current[key] = []
134
+ } else if (!Array.isArray(current[key])) {
135
+ current[key] = [current[key]]
136
+ }
137
+ }
138
+ if (Array.isArray(current[key])) {
139
+ current[key].push(value)
140
+ } else {
141
+ current[key] = value
142
+ }
143
+ }
144
+
145
+ const remove: Array<string> = []
146
+ for (const section of Object.keys(output)) {
147
+ if (typeof output[section] !== "object" || output[section] === null || Array.isArray(output[section])) {
148
+ continue
149
+ }
150
+
151
+ const parts = splitSections(section)
152
+ const last = parts.pop()!
153
+ const key = last.replace(/\\\./g, ".")
154
+ current = output
155
+ for (const part of parts) {
156
+ if (part === "__proto__") {
157
+ continue
158
+ }
159
+ if (!hasOwn.call(current, part) || typeof current[part] !== "object" || current[part] === null) {
160
+ current[part] = Object.create(null)
161
+ }
162
+ current = current[part]
163
+ }
164
+ if (current === output && key === last) {
165
+ continue
166
+ }
167
+ current[key] = output[section]
168
+ remove.push(section)
169
+ }
170
+ for (const section of remove) {
171
+ delete output[section]
172
+ }
173
+ return output
174
+ }