← 返回刚才阅读的位置

知识卡片

结构图卡 · 4545.d.1.b.1

持久化接口隔离存储实现

理解等级:中级

TransactionLogger把记录写删事件、读取历史事件、启动后台处理及报告错误组织成契约。文件与Postgres实现可在核心服务外互换,前提是都遵守相同的顺序、错误和生命周期语义;仅方法签名相同不代表持久性保证也相同。原书构造函数和演进片段不能直接拼成可编译项目。 图仅展示写事件与启动的关键方法,不列全接口;虚线三角为Go的隐式实现关系。

结构图: 类图:

classDiagram
 class TransactionLogger {
  WriteDelete(key string)
  WritePut(key string, value string)
  Run()
 }
 class FileTransactionLogger
 class PostgresTransactionLogger
 TransactionLogger <|.. FileTransactionLogger : 隐式实现
 TransactionLogger <|.. PostgresTransactionLogger : 隐式实现
这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Building a Cloud Native Service · 查看原书依据

      This also affords us another opportunity: given that we’re creating two different implementations of a similar functionality — a transaction log written both to a file and to a database — we can describe our functionality with an interface that both implementations can satisfy. This could come in quite handy, especially if we want to

    参考来源

    - 位置:《Cloud Native Go》第05章《Building a Cloud Native Service》(来源项目book-sources;源文件:extracted/Cloud Native Go (Matthew A. Titmus)/_epub-src/OEBPS/ch05.xhtml) - 结论依据:TransactionLogger把记录写删事件、读取历史事件、启动后台处理及报告错误组织成契约。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。 - 原始内容:This also affords us another opportunity: given that we’re creating two different implementations of a similar functionality — a transaction log written both to a file and to a database — we can describe our functionality with an interface that both implementations can satisfy. This could come in quite handy, especially if we want to