feat: 重构事件处理,添加默认通道和发布逻辑,移除不必要的提供者
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
"{{.ModuleName}}/app/events"
|
||||
"{{.ModuleName}}/providers/event"
|
||||
|
||||
"go.ipao.vip/atom/contracts"
|
||||
)
|
||||
@@ -11,6 +12,8 @@ import (
|
||||
var _ contracts.EventPublisher = (*{{.Name}}Event)(nil)
|
||||
|
||||
type {{.Name}}Event struct {
|
||||
event.DefaultChannel
|
||||
|
||||
ID int64 `json:"id"`
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"{{.ModuleName}}/app/events"
|
||||
"{{.ModuleName}}/app/events/publishers"
|
||||
"{{.ModuleName}}/providers/event"
|
||||
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"github.com/ThreeDotsLabs/watermill/message"
|
||||
@@ -15,6 +16,9 @@ var _ contracts.EventHandler = (*{{.Name}}Subscriber)(nil)
|
||||
|
||||
// @provider(event)
|
||||
type {{.Name}}Subscriber struct {
|
||||
event.DefaultChannel
|
||||
event.DefaultPublishTo
|
||||
|
||||
log *logrus.Entry `inject:"false"`
|
||||
}
|
||||
|
||||
@@ -23,11 +27,6 @@ func (e *{{.Name}}Subscriber) Prepare() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// PublishToTopic implements contracts.EventHandler.
|
||||
func (e *{{.Name}}Subscriber) PublishToTopic() string {
|
||||
return events.TopicProcessed
|
||||
}
|
||||
|
||||
// Topic implements contracts.EventHandler.
|
||||
func (e *{{.Name}}Subscriber) Topic() string {
|
||||
return events.Topic{{.Name}}
|
||||
|
||||
Reference in New Issue
Block a user