← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 6074.d.1.a.3.c.12.a.1.j.1.a.2 · 生成模型:GPT-6

宏展开可能触发外部写入

理解等级:高级

过程宏在展开时执行,因此把远端资源创建放进宏入口,也会把所有触发宏展开的场景变成潜在写操作。书中提醒,IDE 为补全执行过程宏时可能提前创建资源,占用后续编译使用的名称。书中为当时 IntelliJ 补全提供环境变量检测示例,能否识别取决于工具版本和运行方式。

一次失败也可能留下部分已建资源。资源刚创建时,后续关联有时还看不到它。全量重跑又可能报资源已存在。原书据此区分了针对短时失败的重试与通过查询或保存状态避免重复创建;编译成功记录的是当时执行结果,应用之后仍依赖资源持续可用。

相关卡片 [[解析与资源创建分层]]、[[端到端测试验证宏副作用]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Writing an infrastructure DSL 从解析进入部署 · 查看原书依据

      Linking the bucket and lambda may occasionally fail because AWS might mistakenly think that the bucket or lambda you created less than a second ago does not exist. A production-grade version of this project would detect such failures and do a retry. This code only creates resources. If you run it a second time, you will get an error saying that the resources already exist.

    参考来源

    - 位置:《Write Powerful Rust Macros》第09章《Writing an infrastructure DSL》(book-source:extracted/Write Powerful Rust Macros/_epub-src/OEBPS/Text/chapter-9.xhtml#p103) - 结论依据:原文列出刚创建后的暂时不可见和重复创建冲突,并在相邻段说明 IDE 展开也执行创建逻辑。 - 原始内容:Linking the bucket and lambda may occasionally fail because AWS might mistakenly think that the bucket or lambda you created less than a second ago does not exist. A production-grade version of this project would detect such failures and do a retry. This code only creates resources. If you run it a second time, you will get an error saying that the resources already exist.