返回全部动态

可组合构建块:实现弹性异步代码的统一设计

原标题:Composable Building Blocks for Resilient Asynchronous Code

arXiv cs.SE一手来源研究质量 81

AI 摘要

本文提出用高阶组合子统一处理异步代码中的超时、重试、限流、缓存、可重入锁和取消等韧性策略,每个组合子将异步函数映射为同类型异步函数,通过嵌套组合实现完整策略,且不侵入业务逻辑。该设计同时支持 JavaScript 的 Promise 和异步迭代器两种原生异步形态,并提供了可重入锁组合子。作者通过案例展示了如何用这些组合子加固真实包,并发布了开源包 async-com。

以上摘要由 AI 生成,可能存在误差。事实请以原文为准。

正文节选

Composable Building Blocks for Resilient Asynchronous Code Abstract. Asynchronous calls to a network service, database, or language model must cope with transient errors, slow or missing responses, throttling, and atomicity violations. We show how higher-order combinators solve such problems uniformly, including timeouts, retries, rate limiting, caching, reentrant locking, and cancellation. Every combinator maps an async function to another of the same type, so they share a uniform shape and com


发布时间:2026-08-25 12:00
抓取时间:2026-08-25 12:20
来源机构:arXiv
阅读原文arxiv.org