feat: 更新事件主题常量格式,添加前缀以区分事件类型;增强订阅者日志记录,包含主题信息
This commit is contained in:
@@ -127,7 +127,7 @@ func commandNewEventE(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
// 写入或追加 topic 常量,避免重复。
|
// 写入或追加 topic 常量,避免重复。
|
||||||
topicsPath := filepath.Join(baseDir, "app/events/topics.go")
|
topicsPath := filepath.Join(baseDir, "app/events/topics.go")
|
||||||
topicLine := fmt.Sprintf("const Topic%s = %q\n", camelName, snakeName)
|
topicLine := fmt.Sprintf("const Topic%s = %q\n", camelName, "event:"+snakeName)
|
||||||
|
|
||||||
if dryRun {
|
if dryRun {
|
||||||
fmt.Printf("[dry-run] ensure topics file and add constant > %s\n", topicsPath)
|
fmt.Printf("[dry-run] ensure topics file and add constant > %s\n", topicsPath)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ type {{.Name}}Subscriber struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *{{.Name}}Subscriber) Prepare() error {
|
func (e *{{.Name}}Subscriber) Prepare() error {
|
||||||
e.log = logrus.WithField("module", "events.subscribers.{{.Name}}Subscriber")
|
e.log = logrus.WithField("module", "events.subscribers.{{.Name}}Subscriber").WithField("topic", e.Topic())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user