Browse Source

Merge pull request '优化TypeUnion的声明方式' (#4) from feature_gxh into master

gitlink
baohan 2 years ago
parent
commit
d307864a3e
1 changed files with 3 additions and 4 deletions
  1. +3
    -4
      common/pkgs/mq/scanner/event/event.go

+ 3
- 4
common/pkgs/mq/scanner/event/event.go View File

@@ -1,15 +1,14 @@
package event

import (
"gitlink.org.cn/cloudream/common/pkgs/types"
myreflect "gitlink.org.cn/cloudream/common/utils/reflect"
"gitlink.org.cn/cloudream/common/utils/serder"
)

type Event interface{}

var eventUnionEles = serder.NewTypeNameResolver(true)
var EventTypeUnino = serder.NewTypeUnion[Event]("@type", eventUnionEles)
var EventTypeUnino = types.NewTypeUnion[Event]()

func Register[T any]() {
eventUnionEles.Register(myreflect.TypeOf[T]())
EventTypeUnino.Add(myreflect.TypeOf[T]())
}

Loading…
Cancel
Save