PaymentCenter/app/utils/mq/mqmanager.go

35 lines
679 B
Go

package mq
import (
"sync"
)
var (
MqManager = CMqManager{}
once sync.Once
)
type Imq interface {
Produce(name string, log interface{}, delayTime int, args ...interface{}) error
Consume(name string, hand interface{})
DelyConsume(name string, hand interface{})
}
type CMqManager struct {
mqs map[string]Imq
}
func (this *CMqManager) InitMq() {
this.mqs = make(map[string]Imq)
//this.mqs[common.MQ_RABBIT] = RabbitMq{}
//this.mqs[common.MQ_NSQ] = NsqMq{}
//this.mqs[common3.MQ_NATS] = mq.NatsMq{}
//this.mqs[common3.MQ_KFK] = mq.KafkaMq{}
}
func (this *CMqManager) GetMqByName(name string) Imq {
once.Do(func() {
this.InitMq()
})
return this.mqs[name]
}