fix
This commit is contained in:
parent
9c3d9c06b3
commit
a3e0f4b7d7
@ -18,16 +18,14 @@ type ServiceContext struct {
|
|||||||
{{.middleware}}
|
{{.middleware}}
|
||||||
MysqlConn *gorm.DB
|
MysqlConn *gorm.DB
|
||||||
AllModels *gmodel.AllModelsGen
|
AllModels *gmodel.AllModelsGen
|
||||||
RabbitMq map[string]*initalize.QueueItem
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServiceContext(c {{.config}}) *ServiceContext {
|
func NewServiceContext(c {{.config}}) *ServiceContext {
|
||||||
|
initalize.InitRabbitMq(c.SourceRabbitMq, nil)
|
||||||
return &ServiceContext{
|
return &ServiceContext{
|
||||||
Config: c,
|
Config: c,
|
||||||
MysqlConn: initalize.InitMysql(c.SourceMysql),
|
MysqlConn: initalize.InitMysql(c.SourceMysql),
|
||||||
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
|
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
|
||||||
RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil),
|
|
||||||
{{.middlewareAssignment}}
|
{{.middlewareAssignment}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,12 @@ type QueueItem struct {
|
|||||||
Queue amqp.Queue
|
Queue amqp.Queue
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitRabbitMq(url string, config *tls.Config) map[string]*QueueItem {
|
var mapMq = make(map[string]*QueueItem)
|
||||||
|
|
||||||
|
func InitRabbitMq(url string, config *tls.Config) {
|
||||||
|
if url == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
conn, err := amqp.DialTLS(url, config)
|
conn, err := amqp.DialTLS(url, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to connect to RabbitMQ: %v", err)
|
log.Fatalf("Failed to connect to RabbitMQ: %v", err)
|
||||||
@ -23,7 +28,6 @@ func InitRabbitMq(url string, config *tls.Config) map[string]*QueueItem {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to open a channel: %v", err)
|
log.Fatalf("Failed to open a channel: %v", err)
|
||||||
}
|
}
|
||||||
mapMq := make(map[string]*QueueItem)
|
|
||||||
//声明队列
|
//声明队列
|
||||||
for _, queueName := range constants.MQ_QUEUE_ARR {
|
for _, queueName := range constants.MQ_QUEUE_ARR {
|
||||||
q, err := ch.QueueDeclare(
|
q, err := ch.QueueDeclare(
|
||||||
@ -44,5 +48,4 @@ func InitRabbitMq(url string, config *tls.Config) map[string]*QueueItem {
|
|||||||
Queue: q,
|
Queue: q,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mapMq
|
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ func (w *wsConnectItem) SendToCloudRender(data []byte) {
|
|||||||
Option: 1, //0删除 1添加
|
Option: 1, //0删除 1添加
|
||||||
Key: key,
|
Key: key,
|
||||||
}
|
}
|
||||||
|
w.rabbitMq
|
||||||
// TODO 数据发送给云渲染服务器
|
// TODO 数据发送给云渲染服务器
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user