27 lines
688 B
Go
27 lines
688 B
Go
|
|
package message
|
||
|
|
|
||
|
|
import "context"
|
||
|
|
|
||
|
|
type messagePublishConfig interface {
|
||
|
|
GetPublishMsgType()
|
||
|
|
}
|
||
|
|
|
||
|
|
type messageSubscribeConfig interface {
|
||
|
|
GetSubscribeMsgType()
|
||
|
|
}
|
||
|
|
|
||
|
|
// messageUtil 消息队列公共配置接口
|
||
|
|
// 只暴露核心的发布/订阅功能,配置访问器方法不需要在公共接口中
|
||
|
|
type messageUtil interface {
|
||
|
|
// Publish 发布消息
|
||
|
|
Publish(ctx context.Context, msg messagePublishConfig) error
|
||
|
|
// Subscribe 订阅消息
|
||
|
|
Subscribe(ctx context.Context, msg messageSubscribeConfig) error
|
||
|
|
// Ping 检测连接状态
|
||
|
|
ping(ctx context.Context) bool
|
||
|
|
// Reconnect 重连
|
||
|
|
reconnect(ctx context.Context) error
|
||
|
|
// Close 关闭连接
|
||
|
|
close(ctx context.Context) error
|
||
|
|
}
|