← 返回刚才阅读的位置

知识卡片

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

先查询再创建云资源

理解等级:高级

为减少同一资源重复创建,执行层可以先读取远程状态。附录里 Lambda 先按函数名查询,找到时复用;桶则从示例 SDK 的列表结果中检查名称。新建及复用两条 Lambda 路径都返回 ARN,因为后续事件关联只需要这个标识,创建专用响应无法同时描述两条路径。

判断“缺失”需要区分不存在与无权读取、超时等失败。列举资源还要考虑分页,光看第一页可能漏掉已有资源。示例只跳过存在的资源,内存和时限有变更时是否更新仍须独立判断,同一名称也不足以消除查询后到创建之间的并发竞态。

相关卡片 [[宏展开可能触发外部写入]]、[[资源复用仍需核对关联]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Exercise solutions 第 9 章练习:重复部署与状态 · 查看原书依据

      We are ignoring the very real possibility that the error might be caused by a lot of things besides the function not existing. In most cases, this is fine: if there is an error, it will probably show up when we try to create the resource. One error case that can cause real bugs is the user not having the required permissions to list or read functions while still having permission to create them.

    参考来源

    - 位置:《Write Powerful Rust Macros》附录 A《Exercise solutions》(book-source:extracted/Write Powerful Rust Macros/_epub-src/OEBPS/Text/appendix-a.xhtml#p163) - 结论依据:原文指出一概把 get_function 错误视作缺失的风险,并在后文说明返回 ARN、权限、分页和现有配置的边界。 - 原始内容:We are ignoring the very real possibility that the error might be caused by a lot of things besides the function not existing. In most cases, this is fine: if there is an error, it will probably show up when we try to create the resource. One error case that can cause real bugs is the user not having the required permissions to list or read functions while still having permission to create them.