fix
This commit is contained in:
@@ -7,4 +7,15 @@ Auth:
|
||||
AccessSecret: fusen2023
|
||||
AccessExpire: 2592000
|
||||
RefreshAfter: 1592000
|
||||
SourceRabbitMq: amqp://rabbit001:rabbit001129@110.41.19.98:5672
|
||||
SourceRabbitMq: amqp://rabbit001:rabbit001129@110.41.19.98:5672
|
||||
AWS:
|
||||
S3:
|
||||
Credentials:
|
||||
AccessKeyID: AKIAZB2JKUXDPNRP4YT2
|
||||
Secret: sjCEv0JxATnPCxno2KNLm0X8oDc7srUR+4vkYhvm
|
||||
Token:
|
||||
BLMService:
|
||||
Url: "http://18.119.109.254:8999"
|
||||
LogoCombine:
|
||||
#Url: "http://192.168.1.7:8999/LogoCombine"
|
||||
Url: "http://18.119.109.254:8999/LogoCombine"
|
||||
@@ -10,4 +10,19 @@ type Config struct {
|
||||
SourceMysql string
|
||||
Auth types.Auth
|
||||
SourceRabbitMq string
|
||||
AWS struct {
|
||||
S3 struct {
|
||||
Credentials struct {
|
||||
AccessKeyID string
|
||||
Secret string
|
||||
Token string
|
||||
}
|
||||
}
|
||||
}
|
||||
BLMService struct {
|
||||
Url string
|
||||
LogoCombine struct {
|
||||
Url string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
35
server/websocket/internal/handler/rendernotifyhandler.go
Normal file
35
server/websocket/internal/handler/rendernotifyhandler.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"reflect"
|
||||
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
"fusenapi/server/websocket/internal/logic"
|
||||
"fusenapi/server/websocket/internal/svc"
|
||||
"fusenapi/server/websocket/internal/types"
|
||||
)
|
||||
|
||||
func RenderNotifyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req types.RenderNotifyReq
|
||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建一个业务逻辑层实例
|
||||
l := logic.NewRenderNotifyLogic(r.Context(), svcCtx)
|
||||
|
||||
rl := reflect.ValueOf(l)
|
||||
basic.BeforeLogic(w, r, rl)
|
||||
|
||||
resp := l.RenderNotify(&req, userinfo)
|
||||
|
||||
if !basic.AfterLogic(w, r, rl, resp) {
|
||||
basic.NormalAfterLogic(w, r, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/api/websocket/data_transfer",
|
||||
Handler: DataTransferHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/api/websocket/render_notify",
|
||||
Handler: RenderNotifyHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/initalize"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/id_generator"
|
||||
"fusenapi/utils/websocket_data"
|
||||
@@ -71,7 +70,7 @@ type wsConnectItem struct {
|
||||
conn *websocket.Conn //websocket的连接
|
||||
ctx context.Context
|
||||
rabbitMq *initalize.RabbitMqHandle
|
||||
allModels *gmodel.AllModelsGen
|
||||
svcCtx *svc.ServiceContext
|
||||
closeChan chan struct{} //ws连接关闭chan
|
||||
isClose bool //是否已经关闭
|
||||
uniqueId string //ws连接唯一标识
|
||||
@@ -138,7 +137,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User
|
||||
conn: conn,
|
||||
ctx: l.ctx,
|
||||
rabbitMq: l.svcCtx.RabbitMq,
|
||||
allModels: l.svcCtx.AllModels,
|
||||
svcCtx: l.svcCtx,
|
||||
uniqueId: uniqueId,
|
||||
closeChan: make(chan struct{}, 1),
|
||||
inChan: make(chan []byte, 1000),
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/utils/websocket_data"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
// 消费渲染结果数据
|
||||
type MqConsumerRenderResult struct {
|
||||
}
|
||||
|
||||
func (m *MqConsumerRenderResult) Run(ctx context.Context, data []byte) error {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logx.Error("MqConsumerRenderResult panic:", err)
|
||||
}
|
||||
}()
|
||||
logx.Info("接收到MqConsumerRenderResult数据:", string(data))
|
||||
var parseInfo websocket_data.RenderImageNotify
|
||||
if err := json.Unmarshal(data, &parseInfo); err != nil {
|
||||
logx.Error("MqConsumerRenderResult data format err:", err)
|
||||
return nil //不返回错误则就删掉该消息
|
||||
}
|
||||
//遍历websocket链接把数据传进去
|
||||
mapConnPool.Range(func(key, value any) bool {
|
||||
//断言连接
|
||||
ws, ok := value.(wsConnectItem)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
//关闭标识
|
||||
if ws.isClose {
|
||||
return true
|
||||
}
|
||||
//查询有无该渲染任务
|
||||
renderId, ok := ws.renderProperty.renderImageTask[parseInfo.TaskId]
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
b := ws.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{
|
||||
RenderId: renderId,
|
||||
Image: parseInfo.Image,
|
||||
})
|
||||
//删除对应的需要渲染的图片map
|
||||
ws.renderProperty.renderImageTaskCtlChan <- renderImageControlChanItem{
|
||||
Option: 0, //0删除 1添加
|
||||
TaskId: parseInfo.TaskId,
|
||||
RenderId: renderId,
|
||||
}
|
||||
//发送数据到out chan
|
||||
ws.sendToOutChan(b)
|
||||
return true
|
||||
})
|
||||
return nil
|
||||
}
|
||||
100
server/websocket/internal/logic/rendernotifylogic.go
Normal file
100
server/websocket/internal/logic/rendernotifylogic.go
Normal file
@@ -0,0 +1,100 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"fusenapi/constants"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/file"
|
||||
"fusenapi/utils/websocket_data"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/websocket/internal/svc"
|
||||
"fusenapi/server/websocket/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type RenderNotifyLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewRenderNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RenderNotifyLogic {
|
||||
return &RenderNotifyLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *RenderNotifyLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *RenderNotifyLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
||||
|
||||
func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
if req.TaskId == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id")
|
||||
}
|
||||
if req.Image == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image")
|
||||
}
|
||||
if req.UserId == 0 && req.GuestId == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid user_id or guest_id")
|
||||
}
|
||||
// 上传文件
|
||||
var upload = file.Upload{
|
||||
Ctx: l.ctx,
|
||||
MysqlConn: l.svcCtx.MysqlConn,
|
||||
AwsSession: l.svcCtx.AwsSession,
|
||||
}
|
||||
uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{
|
||||
FileHash: req.TaskId,
|
||||
FileData: req.Image,
|
||||
UploadBucket: 1,
|
||||
ApiType: 2,
|
||||
UserId: req.UserId,
|
||||
GuestId: req.GuestId,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "failed to upload render resource image")
|
||||
}
|
||||
//遍历websocket链接把数据传进去
|
||||
mapConnPool.Range(func(key, value any) bool {
|
||||
//断言连接
|
||||
ws, ok := value.(wsConnectItem)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
//关闭标识
|
||||
if ws.isClose {
|
||||
return true
|
||||
}
|
||||
//查询有无该渲染任务
|
||||
renderId, ok := ws.renderProperty.renderImageTask[req.TaskId]
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
b := ws.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{
|
||||
RenderId: renderId,
|
||||
Image: uploadRes.ResourceUrl,
|
||||
})
|
||||
//删除对应的需要渲染的图片map
|
||||
ws.renderProperty.renderImageTaskCtlChan <- renderImageControlChanItem{
|
||||
Option: 0, //0删除 1添加
|
||||
TaskId: req.TaskId,
|
||||
RenderId: renderId,
|
||||
}
|
||||
//发送数据到out chan
|
||||
ws.sendToOutChan(b)
|
||||
return true
|
||||
})
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success")
|
||||
}
|
||||
@@ -3,11 +3,14 @@ package logic
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/service/repositories"
|
||||
"fusenapi/utils/hash"
|
||||
"fusenapi/utils/websocket_data"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// 云渲染属性
|
||||
@@ -48,7 +51,7 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
||||
return
|
||||
}
|
||||
//获取上传最近的logo
|
||||
userMaterial, err := w.allModels.FsUserMaterial.FindLatestOne(w.ctx, w.userId, w.guestId)
|
||||
userMaterial, err := w.svcCtx.AllModels.FsUserMaterial.FindLatestOne(w.ctx, w.userId, w.guestId)
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get user logo"))
|
||||
@@ -56,7 +59,7 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
||||
return
|
||||
}
|
||||
//使用默认logo(id=0)
|
||||
userMaterialDefault, err := w.allModels.FsUserMaterial.FindOneById(w.ctx, 0)
|
||||
userMaterialDefault, err := w.svcCtx.AllModels.FsUserMaterial.FindOneById(w.ctx, 0)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "default logo is not exists"))
|
||||
@@ -77,7 +80,7 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
||||
//生成任务id
|
||||
taskId := hash.JsonHashKey(renderImageData.RenderData)
|
||||
//查询有没有缓存的资源,有就返回######################
|
||||
resource, err := w.allModels.FsResource.FindOneById(w.ctx, taskId)
|
||||
resource, err := w.svcCtx.AllModels.FsResource.FindOneById(w.ctx, taskId)
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logx.Error("failed to find render resource:", err)
|
||||
@@ -100,18 +103,151 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
||||
TaskId: taskId,
|
||||
RenderId: renderImageData.RenderId,
|
||||
}
|
||||
tmpData := websocket_data.AssembleRenderData{
|
||||
TaskId: taskId,
|
||||
RenderId: renderImageData.RenderId,
|
||||
RenderData: renderImageData.RenderData,
|
||||
}
|
||||
d, _ := json.Marshal(tmpData)
|
||||
//发送给对应的流水线组装数据
|
||||
if err = w.rabbitMq.SendMsg(constants.RABBIT_MQ_ASSEMBLE_RENDER_DATA, d); err != nil {
|
||||
logx.Error("发送渲染任务数据到MQ失败:", string(d), "err:", err)
|
||||
//组装数据
|
||||
go w.assembleRenderData(taskId, renderImageData)
|
||||
}
|
||||
|
||||
// 组装数据发送给unity
|
||||
func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.RenderImageReqMsg) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logx.Error("MqConsumerRenderAssemble panic:", err)
|
||||
}
|
||||
}()
|
||||
//根据templateTag获取templateTagId(后续模板表的tag改成template_tag后可能就不需要这个步骤了)
|
||||
templateTag, err := w.svcCtx.AllModels.FsProductTemplateTags.FindOneByTagName(w.ctx, info.RenderData.TemplateTag)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logx.Error("can`t find template tag info by template tag:", info.RenderData.TemplateTag)
|
||||
return
|
||||
}
|
||||
logx.Error("failed to get template tag info")
|
||||
return
|
||||
}
|
||||
logx.Info("发送渲染数据到rabbitmq成功:", string(d))
|
||||
//获取模板(模板标签下的对一个物料的的模板)
|
||||
productTemplate, err := w.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.ctx, info.RenderData.ProductId, fmt.Sprintf("%d", templateTag.Id))
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logx.Error("template info is not found")
|
||||
return
|
||||
}
|
||||
logx.Error("failed to get template info:", err)
|
||||
return
|
||||
}
|
||||
//获取刀版图
|
||||
res, err := w.svcCtx.Repositories.ImageHandle.LogoCombine(w.ctx, &repositories.LogoCombineReq{
|
||||
UserId: info.RenderData.UserId,
|
||||
GuestId: info.RenderData.GuestId,
|
||||
TemplateId: productTemplate.Id,
|
||||
TemplateTag: info.RenderData.TemplateTag,
|
||||
Website: info.RenderData.Website,
|
||||
Slogan: info.RenderData.Slogan,
|
||||
Address: info.RenderData.Address,
|
||||
Phone: info.RenderData.Phone,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error("合成刀版图失败:", err)
|
||||
return
|
||||
}
|
||||
combineImage := "" //刀版图
|
||||
if res != nil && res.ResourceUrl != nil {
|
||||
combineImage = *res.ResourceUrl
|
||||
} else {
|
||||
logx.Error("合成刀版图失败,合成的刀版图是空指针:", err)
|
||||
return
|
||||
}
|
||||
logx.Info("合成刀版图成功:", *res.ResourceUrl)
|
||||
//获取渲染设置信息
|
||||
element, err := w.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.ctx, *productTemplate.ModelId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logx.Error("element info is not found,model_id = ?", *productTemplate.ModelId)
|
||||
return
|
||||
}
|
||||
logx.Error("failed to get element list,", err)
|
||||
return
|
||||
}
|
||||
//组装数据
|
||||
refletion := -1
|
||||
if element.Refletion != nil && *element.Refletion != "" {
|
||||
refletion, err = strconv.Atoi(*element.Refletion)
|
||||
}
|
||||
//组装data数据
|
||||
var mode map[string]interface{}
|
||||
if element.Mode != nil && *element.Mode != "" {
|
||||
if err = json.Unmarshal([]byte(*element.Mode), &mode); err != nil {
|
||||
logx.Error("faile to parse element mode json:", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
tempData := make([]map[string]interface{}, 0, 3)
|
||||
if element.Base != nil && *element.Base != "" {
|
||||
tempData = append(tempData, map[string]interface{}{
|
||||
"name": "model",
|
||||
"data": "0," + combineImage + "," + *element.Base,
|
||||
"type": "other",
|
||||
"layer": "0",
|
||||
"is_update": 1,
|
||||
"mode": mode["model"],
|
||||
})
|
||||
}
|
||||
if element.Shadow != nil && *element.Shadow != "" {
|
||||
tempData = append(tempData, map[string]interface{}{
|
||||
"name": "shadow",
|
||||
"data": *element.Shadow,
|
||||
"type": "other",
|
||||
"layer": "0",
|
||||
"is_update": 0,
|
||||
"mode": mode["shadow"],
|
||||
})
|
||||
}
|
||||
if element.ModelP != nil && *element.ModelP != "" {
|
||||
tempData = append(tempData, map[string]interface{}{
|
||||
"name": "model_P",
|
||||
"data": "0," + *element.ModelP,
|
||||
"type": "other",
|
||||
"layer": "0",
|
||||
"is_update": 0,
|
||||
"mode": mode["model_P"],
|
||||
})
|
||||
}
|
||||
result := []interface{}{
|
||||
map[string]interface{}{
|
||||
"light": *element.Light,
|
||||
"refletion": refletion,
|
||||
"scale": *element.Scale,
|
||||
"sku_id": info.RenderData.ProductId,
|
||||
"tid": *element.Title,
|
||||
"rotation": *element.Rotation,
|
||||
"filePath": "", //todo 文件路径,针对千人千面
|
||||
"data": tempData,
|
||||
},
|
||||
}
|
||||
sendData := map[string]interface{}{
|
||||
"id": taskId,
|
||||
"order_id": 0,
|
||||
"user_id": info.RenderData.UserId,
|
||||
"guest_id": info.RenderData.GuestId,
|
||||
"sku_ids": []int64{info.RenderData.ProductId},
|
||||
"tids": []string{*element.Title},
|
||||
"data": result,
|
||||
"is_thousand_face": 0,
|
||||
"folder": "", //todo 千人千面需要使用
|
||||
}
|
||||
/*b, _ := json.Marshal(sendData)
|
||||
if err = rabbitmq.SendMsg(constants.RABBIT_MQ_TO_UNITY, b); err != nil {
|
||||
logx.Error("发送渲染组装数据到rabbitmq失败:", err)
|
||||
return nil
|
||||
}
|
||||
logx.Info("发送渲染组装数据到unity成功")*/
|
||||
// todo 请求unity接口 /api/render/queue/push
|
||||
logx.Info(sendData["id"])
|
||||
//模拟发送回去(unity部署后要去掉)
|
||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{
|
||||
RenderId: info.RenderId,
|
||||
Image: "https://fusenh5.kayue.cn:8011/storage/test/final_k8TgMUxauc_temp.png",
|
||||
}))
|
||||
return
|
||||
}
|
||||
|
||||
// 操作连接中渲染任务的增加/删除
|
||||
|
||||
@@ -4,6 +4,9 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/server/websocket/internal/config"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"net/http"
|
||||
|
||||
"fusenapi/initalize"
|
||||
@@ -16,17 +19,28 @@ import (
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
RabbitMq *initalize.RabbitMqHandle
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
RabbitMq *initalize.RabbitMqHandle
|
||||
AwsSession *session.Session
|
||||
Repositories *initalize.Repositories
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
config := aws.Config{
|
||||
Credentials: credentials.NewStaticCredentials(c.AWS.S3.Credentials.AccessKeyID, c.AWS.S3.Credentials.Secret, c.AWS.S3.Credentials.Token),
|
||||
}
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
MysqlConn: initalize.InitMysql(c.SourceMysql),
|
||||
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
|
||||
RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil),
|
||||
Config: c,
|
||||
MysqlConn: initalize.InitMysql(c.SourceMysql),
|
||||
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
|
||||
RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil),
|
||||
AwsSession: session.Must(session.NewSession(&config)),
|
||||
Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{
|
||||
GormDB: initalize.InitMysql(c.SourceMysql),
|
||||
BLMServiceUrl: &c.BLMService.Url,
|
||||
AwsSession: session.Must(session.NewSession(&config)),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,13 @@ import (
|
||||
"fusenapi/utils/basic"
|
||||
)
|
||||
|
||||
type RenderNotifyReq struct {
|
||||
TaskId string `json:"task_id"` //任务id
|
||||
UserId int64 `json:"user_id"`
|
||||
GuestId int64 `json:"guest_id"`
|
||||
Image string `json:"image"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/server/websocket/internal/logic"
|
||||
"net/http"
|
||||
|
||||
"fusenapi/utils/auth"
|
||||
@@ -30,12 +27,6 @@ func main() {
|
||||
defer server.Stop()
|
||||
|
||||
ctx := svc.NewServiceContext(c)
|
||||
//消费渲染结果队列
|
||||
ctx1 := context.Background()
|
||||
ctx2, cancel := context.WithCancel(ctx1)
|
||||
ctx2 = context.WithValue(ctx2, "allmodels", ctx.AllModels)
|
||||
defer cancel()
|
||||
go ctx.RabbitMq.Consume(ctx2, constants.RABBIT_MQ_RENDER_RESULT_DATA, &logic.MqConsumerRenderResult{})
|
||||
handler.RegisterHandlers(server, ctx)
|
||||
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
|
||||
server.Start()
|
||||
|
||||
Reference in New Issue
Block a user