feat: 重构事件处理,添加默认通道和发布逻辑,移除不必要的提供者
This commit is contained in:
30
templates/project/providers/event/channel.go.tpl
Normal file
30
templates/project/providers/event/channel.go.tpl
Normal file
@@ -0,0 +1,30 @@
|
||||
package event
|
||||
|
||||
import "go.ipao.vip/atom/contracts"
|
||||
|
||||
const (
|
||||
Go contracts.Channel = "go"
|
||||
Kafka contracts.Channel = "kafka"
|
||||
Redis contracts.Channel = "redis"
|
||||
Sql contracts.Channel = "sql"
|
||||
)
|
||||
|
||||
type DefaultPublishTo struct{}
|
||||
|
||||
func (d *DefaultPublishTo) PublishTo() (contracts.Channel, string) {
|
||||
return Go, "event:processed"
|
||||
}
|
||||
|
||||
type DefaultChannel struct{}
|
||||
|
||||
func (d *DefaultChannel) Channel() contracts.Channel { return Go }
|
||||
|
||||
// kafka
|
||||
type KafkaChannel struct{}
|
||||
|
||||
func (k *KafkaChannel) Channel() contracts.Channel { return Kafka }
|
||||
|
||||
// kafka
|
||||
type RedisChannel struct{}
|
||||
|
||||
func (k *RedisChannel) Channel() contracts.Channel { return Redis }
|
||||
Reference in New Issue
Block a user