first commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const ResQueueTopic = "res-queue-topic"
|
||||
const UserQueueTopic = "user-queue-topic"
|
||||
|
||||
type ResQueuePayload struct {
|
||||
Type string // insert | delete | update
|
||||
Res Resource // 变更资源
|
||||
Result sql.Result // 执行结果
|
||||
}
|
||||
|
||||
type UserQueuePayload struct {
|
||||
Type string // insert | delete | update | select
|
||||
User User // 操作用户
|
||||
Res Resource // 变更资源
|
||||
Result sql.Result // 执行结果
|
||||
Old []map[string]any // 旧数据
|
||||
New []map[string]any // 新数据
|
||||
}
|
||||
|
||||
type Queue interface {
|
||||
// 消息推送
|
||||
// @param topic 订阅的主题
|
||||
// @param msg 传递的消息
|
||||
Publish(topic string, msg any) error
|
||||
|
||||
// 消息订阅
|
||||
// @description 传入订阅的主题,即可完成订阅
|
||||
// @param topic 订阅的主题
|
||||
// @return channel 通道用来接收数据
|
||||
Subscribe(topic string) (sub <-chan any, err error)
|
||||
|
||||
// 取消订阅
|
||||
// @param topic 订阅的主题
|
||||
// @param sub 消息订阅的通道
|
||||
Unsubscribe(topic string, sub <-chan any) error
|
||||
|
||||
// 关闭消息队列
|
||||
Close()
|
||||
|
||||
// 设置消息容量
|
||||
// @description 控制消息队列的大小
|
||||
SetConditions(capacity int)
|
||||
|
||||
// 获取主题消息内容
|
||||
GetPayload(sub <-chan any) any
|
||||
}
|
||||
Reference in New Issue
Block a user