Browse Source

优化TypeUnion的声明方式

gitlink
Sydonian 2 years ago
parent
commit
a256048496
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