Files
kami_gateway/main.go

56 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"gateway/internal/config"
_ "gateway/internal/models"
"gateway/internal/otelTrace"
"gateway/internal/proxy"
_ "gateway/internal/routers"
"gateway/internal/schema/query"
"gateway/internal/service"
_ "gateway/internal/service/message"
"gateway/internal/service/notify"
_ "gateway/internal/service/supplier/third_party"
"log"
_ "net/http/pprof"
"github.com/beego/beego/v2/server/web"
"go.uber.org/zap"
"github.com/beego/beego/v2/server/web/context"
_ "github.com/go-sql-driver/mysql"
)
func logRequest(ctx *context.Context) {
otelTrace.Logger.WithContext(otelTrace.InitCtx).Info("Request", zap.String("method", ctx.Input.Method()), zap.String("uri", ctx.Input.URI()), zap.String("ip", ctx.Input.IP()), zap.Any("params", ctx.Input.Params()), zap.Any("body", ctx.Input.Data()))
}
func main() {
config.GetMQAddress()
// 初始化代理池
if err := proxy.InitProxyPool(); err != nil {
log.Printf("初始化代理池失败: %v", err)
return
}
// cleanup1, cleanup2, cleanup3 := otelTrace.InitTracer()
// defer func() {
// if cleanup1 != nil {
// _ = cleanup1(otelTrace.InitCtx)
// }
// if cleanup2 != nil {
// _ = cleanup2(otelTrace.InitCtx)
// }
// if cleanup3 != nil {
// _ = cleanup3(otelTrace.InitCtx)
// }
// }()
go notify.CreateOrderNotifyConsumer(otelTrace.InitCtx)
// go query.CreatePayForQueryConsumer(otelTrace.InitCtx)
go service.OrderSettleInit(otelTrace.InitCtx)
go query.CreateSupplierOrderQueryCuConsumer(otelTrace.InitCtx)
web.InsertFilter("*", web.BeforeRouter, logRequest)
otelTrace.Logger.WithContext(otelTrace.InitCtx).Info("gateway start")
web.Run()
}