Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: proposal: generator(all): Introduce the model struct diff mechanism , the ormDiffTag , and the generator #314

Open
scbizu opened this issue Dec 18, 2023 · 0 comments
Assignees
Labels
v2 ezorm v2

Comments

@scbizu
Copy link
Member

scbizu commented Dec 18, 2023

背景

在一些特定的业务场景(审计日志)下,往往会需要在 model 层 (不管是 M1 -> M 还是 P2 ->(C3) -> M ) 记录一些 changelog(auditlog) 变化

Proposal

The Generator (diff模板生成)

在 (YAML)model struct 上生成 diff 方法,diff 方法接受另一个 M (提供 option , 可以带入一个 P -> C -> M 的转换过程)。

// 方法摘要
func (m *Model) Diff(m1 *Model) (bool,Differ,error)

The Differ

Differ 用来描述一次具体的DIFF结果,DIFF 结果可以按照不同业务场景组装:

  • Extras: 提供额外信息展示
  • OnKey: 用来描述oplog是否需要在 Key 的层级聚合
type Differ struct{
   // not export field , export behavior as method
   before *M
  // not export field , export behavior as method
  after *M
}

Footnotes

  1. M: Model Struct

  2. P: (API)Protocol(ProtoBuffer/Thrift/Json-To-Go) Struct

  3. C: The Converter between P <-> M

@scbizu scbizu added the v2 ezorm v2 label Dec 18, 2023
@scbizu scbizu self-assigned this Dec 18, 2023
@scbizu scbizu changed the title proposal: generator(all): Introduce the model struct diff mechanism , the ormDiffTag , and the generator Draft: proposal: generator(all): Introduce the model struct diff mechanism , the ormDiffTag , and the generator Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 ezorm v2
Projects
None yet
Development

No branches or pull requests

1 participant