主要变更: 1. 重构NATS、RabbitMQ和Redis连接管理模块,支持多数据源配置 2. 统一连接管理接口,增加数据源名称参数 3. 优化连接状态检查和错误处理 4. 增加连接池管理和资源清理机制 5. 改进日志输出格式和内容
33 lines
864 B
Go
33 lines
864 B
Go
package message
|
|
|
|
import "context"
|
|
|
|
type messagePublishConfig interface {
|
|
GetPublishMsgType()
|
|
}
|
|
|
|
type messagePublishDelayConfig interface {
|
|
GetPublishDelayMsgType()
|
|
}
|
|
|
|
type messageSubscribeConfig interface {
|
|
GetSubscribeMsgType()
|
|
}
|
|
|
|
// messageUtil 消息队列公共配置接口
|
|
// 只暴露核心的发布/订阅功能,配置访问器方法不需要在公共接口中
|
|
type messageUtil interface {
|
|
// Publish 发布消息
|
|
Publish(ctx context.Context, msg messagePublishConfig) error
|
|
// PublishDelay 发布延迟消息
|
|
PublishDelay(ctx context.Context, msg messagePublishDelayConfig) error
|
|
// Subscribe 订阅消息
|
|
Subscribe(ctx context.Context, msg messageSubscribeConfig) error
|
|
// Ping 检测连接状态
|
|
Ping(ctx context.Context) bool
|
|
// Connect 连接
|
|
Connect(ctx context.Context) error
|
|
// Close 关闭连接
|
|
Close(ctx context.Context) error
|
|
}
|