规划基于redis pub/sub 的驱动实现
This commit is contained in:
@ -18,6 +18,7 @@ type EventData struct {
|
||||
Host string `json:"host"` // 触发事件host
|
||||
Timestamp int64 `json:"timestamp"` // 触发时间,纳秒级时间戳
|
||||
SystemTimestamp int64 `json:"system_timestamp"` // 发送时的系统时间
|
||||
Key string `json:"key"` // 会基于当前值进行hash, 决定消息分区, 不指定则随机生成
|
||||
Data any `json:"data"` // 发送的数据
|
||||
}
|
||||
|
||||
@ -27,8 +28,10 @@ type EventData struct {
|
||||
//
|
||||
// Date : 15:56 2024/6/25
|
||||
type SendResult struct {
|
||||
Data *EventData `json:"data"` // 发送的数据
|
||||
IsSuccess bool `json:"is_success"` // 是否发送成功
|
||||
FailReason string `json:"fail_reason"` // 失败原因
|
||||
Extension map[string]any `json:"extension"` // 扩展数据
|
||||
Data *EventData `json:"data"` // 发送的数据
|
||||
PartitionNum int `json:"partition_num"` // 分区索引编号
|
||||
Topic string `json:"topic"` // 使用的真实topic
|
||||
IsSuccess bool `json:"is_success"` // 是否发送成功
|
||||
FailReason string `json:"fail_reason"` // 失败原因
|
||||
Extension map[string]any `json:"extension"` // 扩展数据
|
||||
}
|
||||
|
22
define/redis.go
Normal file
22
define/redis.go
Normal file
@ -0,0 +1,22 @@
|
||||
// Package define ...
|
||||
//
|
||||
// Description : define ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2024-06-25 16:24
|
||||
package define
|
||||
|
||||
const (
|
||||
DefaultPartitionNum = 1
|
||||
)
|
||||
|
||||
// RedisEventPubSubConfig redis事件配置
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:25 2024/6/25
|
||||
type RedisEventPubSubConfig struct {
|
||||
Topic string `json:"topic"` // topic key, 不指定随机生成
|
||||
PartitionNum int `json:"partition_num"` // 多少个分区, 默认值 : 1
|
||||
}
|
Reference in New Issue
Block a user