← 返回刚才阅读的位置

知识卡片

结构图卡 · 3498.a.1

依赖注入隔离发现

理解等级:中级

依赖注入让栈只声明子网列表等输入,部署机制在外部发现并传入值。消费者关心使用何种资源,不必知道其来自状态文件、注册表还是测试夹具。这样可替换发现机制和部署上下文;依赖本身仍存在,只是发现实现不再嵌入消费者。

结构图:

flowchart TD
 A[提供者或测试夹具] --> B[外部发现机制]
 B -->|资源标识参数| C[消费者栈]
 C --> D[部署消费者资源]
这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 集成基础设施栈 · 查看原书依据

      Dependency injection (DI) is an approach that decouples code from the implementation details of discovering its dependencies. The code component declares its dependencies as configuration parameters, and the deployment mechanism passes in the values for those parameters when provisioning the component. The implementation of dependency discovery is handled outside the stack, as I’ll discuss next.

    参考来源

    - 位置:《Infrastructure As Code》第9章《集成基础设施栈》(来源项目:book-sources;源文件:extracted/Infrastructure As Code/_epub-src/OEBPS/ch09.html) - 结论依据:原文说明依赖注入让栈只声明子网列表等输入,部署机制在外部发现并传入值;本卡据此解释其用途及适用边界。 - 原始内容:Dependency injection (DI) is an approach that decouples code from the implementation details of discovering its dependencies. The code component declares its dependencies as configuration parameters, and the deployment mechanism passes in the values for those parameters when provisioning the component. The implementation of dependency discovery is handled outside the stack, as I’ll discuss next.