提交 c4783e62 authored 作者: mooncake9527's avatar mooncake9527

change dir

上级 b9c4159d
package application
import (
"context"
"time"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/app"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/tracer"
)
func Close(servers []app.IServer) []app.Close {
var closes []app.Close
for _, s := range servers {
closes = append(closes, s.Stop)
}
closes = append(closes, func() error {
return database.CloseDB()
})
cacheType := ""
config.Read(func(c *config.Config) {
cacheType = c.App.CacheType
})
if cacheType == "redis" {
closes = append(closes, func() error {
return database.CloseRedis()
})
}
enableTrace := false
config.Read(func(c *config.Config) {
enableTrace = c.App.Middleware.Trace.Enable
})
if enableTrace {
closes = append(closes, func() error {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) //nolint
defer cancel()
return tracer.Close(ctx)
})
}
closes = append(closes, func() error {
return logger.Sync()
})
return closes
}
package application
import (
"net/http"
"strconv"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/app"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/server"
)
func CreateServices(handler http.Handler) []app.IServer {
port := 8080
config.Read(func(c *config.Config) {
port = c.HTTP.Port
})
var servers []app.IServer
httpAddr := ":" + strconv.Itoa(port)
httpServer := server.NewHTTPServer(httpAddr, handler)
servers = append(servers, httpServer)
return servers
}
package xpkg package application
import ( import (
"context" "context"
"fmt" "fmt"
"os" "os"
"runtime"
"strconv" "strconv"
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/config" "gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/database" "gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/global" "gitlab.wanzhuangkj.com/tush/xpkg/global"
"gitlab.wanzhuangkj.com/tush/xpkg/ips" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/ips"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/stat"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/tracer"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/rd/nacos" "gitlab.wanzhuangkj.com/tush/xpkg/rd/nacos"
"gitlab.wanzhuangkj.com/tush/xpkg/stat"
"gitlab.wanzhuangkj.com/tush/xpkg/tracer"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/dxsf" "gitlab.wanzhuangkj.com/tush/xpkg/utils/dxsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils" "gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf" "gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/app"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
) )
func init() { func parseInit() {
if confType, ok := os.LookupEnv("CONF_TYPE"); (ok && sliceUtils.NotContains([]string{"local", "nacos", "consul"}, confType)) || !ok { if confType, ok := os.LookupEnv("CONF_TYPE"); (ok && sliceUtils.NotContains([]string{"local", "nacos", "consul"}, confType)) || !ok {
return return
} }
if err := config.Parse(); err != nil { if err := config.ParseConf(); err != nil {
logger.Fatal(err.Error()) fmt.Println(err.Error())
} }
logger.Info("[conf] parse conf finish.")
if err := xsf.Init(); err != nil { if err := xsf.Init(); err != nil {
logger.Fatal(err.Error()) logger.Fatal(err.Error())
} }
logger.Info("[xsf] initialized.")
if err := dxsf.Init(); err != nil { if err := dxsf.Init(); err != nil {
logger.Fatal(err.Error()) logger.Fatal(err.Error())
} }
if err := Init(); err != nil { logger.Info("[dxsf] initialized.")
if err := initOthers(); err != nil {
logger.Fatal(err.Error()) logger.Fatal(err.Error())
} }
} }
func Init() (err error) { type Application struct {
app *app.App
h func() *gin.Engine
}
func (x *Application) Run() {
defer Recover()
parseInit()
services := CreateServices(x.h())
closes := Close(services)
x.app = app.New(services, closes)
x.app.Run()
}
func Recover() {
if r := recover(); r != nil {
pc, file, line, _ := runtime.Caller(3)
logger.Fatalf("recovered panic at %s[%s:%d]: %v\n", runtime.FuncForPC(pc).Name(), file, line, r)
}
}
func New(h func() *gin.Engine) *Application {
return &Application{
h: h,
}
}
// init logger,trace,stat,database,cache,rd...
func initOthers() (err error) {
conf := config.Cfg conf := config.Cfg
if err := initLogger(conf); err != nil { if err := initLogger(conf); err != nil {
return err return err
...@@ -73,13 +108,14 @@ func Init() (err error) { ...@@ -73,13 +108,14 @@ func Init() (err error) {
database.InitCache(conf.App.CacheType) database.InitCache(conf.App.CacheType)
eventbus.Eb.Publish(ctx, eventbus.TopicCacheInitFinish) eventbus.Eb.Publish(ctx, eventbus.TopicCacheInitFinish)
if conf.App.CacheType != "" { if conf.App.CacheType != "" {
logger.Info(fmt.Sprintf("[%s] initialized", conf.App.CacheType)) logger.Info(fmt.Sprintf("[cache-%s] initialized", conf.App.CacheType))
} }
rdt := conf.App.RegistryDiscoveryType rdt := conf.App.RegistryDiscoveryType
if rdt == "nacos" { if rdt == "nacos" {
if err := nacosRegisterInstance(); err != nil { if err := nacosRegisterInstance(); err != nil {
return err return err
} }
logger.Info("[rd] initialized.")
} }
eventbus.Eb.Publish(ctx, eventbus.TopicCoreInitFinish) eventbus.Eb.Publish(ctx, eventbus.TopicCoreInitFinish)
return nil return nil
......
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"time" "time"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/third/oss" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/oss"
) )
var Cfg = &Config{ var Cfg = &Config{
......
...@@ -7,9 +7,9 @@ import ( ...@@ -7,9 +7,9 @@ import (
"github.com/hashicorp/consul/api" "github.com/hashicorp/consul/api"
"github.com/spf13/viper" "github.com/spf13/viper"
"gitlab.wanzhuangkj.com/tush/xpkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/hashUtils" "gitlab.wanzhuangkj.com/tush/xpkg/utils/hashUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
) )
type ConsulConfFetcher struct { type ConsulConfFetcher struct {
......
...@@ -8,8 +8,8 @@ import ( ...@@ -8,8 +8,8 @@ import (
"github.com/spf13/cast" "github.com/spf13/cast"
"github.com/spf13/viper" "github.com/spf13/viper"
"gitlab.wanzhuangkj.com/tush/xpkg/eventbus" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
) )
var ( var (
...@@ -21,7 +21,7 @@ type IExtend interface { ...@@ -21,7 +21,7 @@ type IExtend interface {
Unlock() Unlock()
} }
func Parse() (err error) { func ParseConf() (err error) {
if hostname := os.Getenv("HOSTNAME"); hostname != "" { if hostname := os.Getenv("HOSTNAME"); hostname != "" {
Cfg.App.PodName = hostname Cfg.App.PodName = hostname
} }
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"github.com/fsnotify/fsnotify" "github.com/fsnotify/fsnotify"
"github.com/spf13/viper" "github.com/spf13/viper"
......
...@@ -7,8 +7,8 @@ import ( ...@@ -7,8 +7,8 @@ import (
"github.com/nacos-group/nacos-sdk-go/clients/config_client" "github.com/nacos-group/nacos-sdk-go/clients/config_client"
"github.com/nacos-group/nacos-sdk-go/common/constant" "github.com/nacos-group/nacos-sdk-go/common/constant"
"github.com/nacos-group/nacos-sdk-go/vo" "github.com/nacos-group/nacos-sdk-go/vo"
"gitlab.wanzhuangkj.com/tush/xpkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"go.uber.org/zap" "go.uber.org/zap"
) )
......
...@@ -5,8 +5,8 @@ import ( ...@@ -5,8 +5,8 @@ import (
"strings" "strings"
"gitlab.wanzhuangkj.com/tush/xpkg/config" "gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
) )
var ( var (
......
...@@ -6,9 +6,9 @@ import ( ...@@ -6,9 +6,9 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils" "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/config" "gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/mysql" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/mysql"
"gitlab.wanzhuangkj.com/tush/xpkg/utils" "gitlab.wanzhuangkj.com/tush/xpkg/utils"
) )
......
...@@ -7,9 +7,9 @@ import ( ...@@ -7,9 +7,9 @@ import (
"github.com/dgraph-io/ristretto" "github.com/dgraph-io/ristretto"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/config" "gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/goredis" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/goredis"
"gitlab.wanzhuangkj.com/tush/xpkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/tracer" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/tracer"
) )
var ( var (
......
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/errcode" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/utils" "gitlab.wanzhuangkj.com/tush/xpkg/utils"
) )
......
...@@ -3,10 +3,10 @@ package middleware ...@@ -3,10 +3,10 @@ package middleware
import ( import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response" "gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/jwt" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/jwt"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils" "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf" "gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
) )
...@@ -110,6 +110,17 @@ func Auth(opts ...JwtOption) gin.HandlerFunc { ...@@ -110,6 +110,17 @@ func Auth(opts ...JwtOption) gin.HandlerFunc {
} }
} }
func JwtFields() gin.HandlerFunc {
return func(c *gin.Context) {
params := c.Request.URL.Query()
for key, values := range params {
if len(values) > 0 {
c.Set(key, values[0])
}
}
}
}
// ------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------
// VerifyCustomFn verify custom function, tokenTail10 is the last 10 characters of the token. // VerifyCustomFn verify custom function, tokenTail10 is the last 10 characters of the token.
......
...@@ -5,9 +5,9 @@ import ( ...@@ -5,9 +5,9 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/container/group"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response" "gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/shield/circuitbreaker" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/container/group"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/circuitbreaker"
) )
// ErrNotAllowed error not allowed. // ErrNotAllowed error not allowed.
......
...@@ -11,10 +11,10 @@ import ( ...@@ -11,10 +11,10 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/container/group"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response" "gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/container/group"
"gitlab.wanzhuangkj.com/tush/xpkg/shield/circuitbreaker" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/circuitbreaker"
"gitlab.wanzhuangkj.com/tush/xpkg/utils" "gitlab.wanzhuangkj.com/tush/xpkg/utils"
) )
......
...@@ -2,13 +2,14 @@ package middleware ...@@ -2,13 +2,14 @@ package middleware
import ( import (
"bytes" "bytes"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli/entity"
"io" "io"
"net/http" "net/http"
"strings" "strings"
"time" "time"
"gitlab.wanzhuangkj.com/tush/xpkg/ips" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli/entity"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/ips"
ctxUtils "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils" ctxUtils "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
......
...@@ -8,8 +8,8 @@ import ( ...@@ -8,8 +8,8 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response" "gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/utils" "gitlab.wanzhuangkj.com/tush/xpkg/utils"
ctxUtil "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils" ctxUtil "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
) )
......
package middleware
import (
"net/http"
"time"
"github.com/gin-gonic/gin"
"github.com/redis/go-redis/v9"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware/ratelimiter"
srl "gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware/sync_ratelimiter"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/ips"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
)
func IPRateLimiter(windowSize time.Duration, maxRequests int) func(c *gin.Context) {
rl := ratelimiter.NewIPRateLimiter(windowSize, maxRequests)
return func(c *gin.Context) {
clientIP := ips.GetClientIP(c)
if rl.Allow(clientIP) {
c.Next()
} else {
Fail(c, errcode.TooManyRequests.Code(), errcode.TooManyRequests.Msg())
}
}
}
func SyncIPRateLimiter(windowSize time.Duration, maxRequests int64, cli redis.Cmdable) func(c *gin.Context) {
rl := srl.NewIPRateLimiter(
srl.WithWindowSize(windowSize),
srl.WithMaxRequests(maxRequests),
srl.WithLogger(logger.Get()),
srl.WithRedisCli(cli),
)
return func(c *gin.Context) {
clientIP := ips.GetClientIP(c)
ctx := ctxUtils.WrapCtx(c)
if rl.Allow(ctx, clientIP) {
c.Next()
} else {
Fail(c, errcode.TooManyRequests.Code(), errcode.TooManyRequests.Msg())
}
}
}
func Fail(c *gin.Context, code int, msg string, data ...any) {
c.AbortWithStatusJSON(http.StatusOK, response.Result{Code: code, Msg: msg, Data: nil, TimeStamp: time.Now().Unix(), TraceID: ctxUtils.GetGinCtxTid(c)})
}
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response" "gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
rl "gitlab.wanzhuangkj.com/tush/xpkg/shield/ratelimit" rl "gitlab.wanzhuangkj.com/tush/xpkg/pkg/shield/ratelimit"
) )
// ErrLimitExceed is returned when the rate limiter is // ErrLimitExceed is returned when the rate limiter is
......
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response" "gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/utils" "gitlab.wanzhuangkj.com/tush/xpkg/utils"
) )
......
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"time" "time"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/response" "gitlab.wanzhuangkj.com/tush/xpkg/gin/response"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/utils" "gitlab.wanzhuangkj.com/tush/xpkg/utils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
......
...@@ -8,14 +8,14 @@ import ( ...@@ -8,14 +8,14 @@ import (
"strconv" "strconv"
"time" "time"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli/entity" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli/entity"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gitlab.wanzhuangkj.com/tush/xpkg/errcode" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
ctxUtils "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils" ctxUtils "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
) )
const CustomErrorCode = 0 const CustomErrorCode = 0
......
...@@ -10,8 +10,8 @@ import ( ...@@ -10,8 +10,8 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"gitlab.wanzhuangkj.com/tush/xpkg/errcode" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli"
"gitlab.wanzhuangkj.com/tush/xpkg/utils" "gitlab.wanzhuangkj.com/tush/xpkg/utils"
) )
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
ginSwagger "github.com/swaggo/gin-swagger" ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/swag" "github.com/swaggo/swag"
"gitlab.wanzhuangkj.com/tush/xpkg/gofile" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/gofile"
) )
// DefaultRouter default swagger router, request url is http://<ip:port>/swagger/index.html // DefaultRouter default swagger router, request url is http://<ip:port>/swagger/index.html
......
...@@ -12,16 +12,16 @@ import ( ...@@ -12,16 +12,16 @@ import (
ginSwagger "github.com/swaggo/gin-swagger" ginSwagger "github.com/swaggo/gin-swagger"
"gitlab.wanzhuangkj.com/tush/xpkg/config" "gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/consts" "gitlab.wanzhuangkj.com/tush/xpkg/consts"
"gitlab.wanzhuangkj.com/tush/xpkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/handlerfunc" "gitlab.wanzhuangkj.com/tush/xpkg/gin/handlerfunc"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware" "gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware/metrics" "gitlab.wanzhuangkj.com/tush/xpkg/gin/middleware/metrics"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/prof" "gitlab.wanzhuangkj.com/tush/xpkg/gin/prof"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/validator" "gitlab.wanzhuangkj.com/tush/xpkg/gin/validator"
"gitlab.wanzhuangkj.com/tush/xpkg/ips" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/errcode"
"gitlab.wanzhuangkj.com/tush/xpkg/jwt" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/ips"
"gitlab.wanzhuangkj.com/tush/xpkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/jwt"
"gitlab.wanzhuangkj.com/tush/xpkg/text" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/text"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/webLogUtils" "gitlab.wanzhuangkj.com/tush/xpkg/utils/webLogUtils"
xvalidator "gitlab.wanzhuangkj.com/tush/xpkg/xcommon/validator" xvalidator "gitlab.wanzhuangkj.com/tush/xpkg/xcommon/validator"
) )
......
...@@ -10,9 +10,9 @@ import ( ...@@ -10,9 +10,9 @@ import (
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
"gitlab.wanzhuangkj.com/tush/xpkg/prof" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/prof"
xlogger "gitlab.wanzhuangkj.com/tush/xpkg/logger" xlogger "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
) )
// IServer server interface // IServer server interface
......
...@@ -6,8 +6,8 @@ import ( ...@@ -6,8 +6,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"gitlab.wanzhuangkj.com/tush/xpkg/encoding" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/gotest" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/gotest"
"gitlab.wanzhuangkj.com/tush/xpkg/utils" "gitlab.wanzhuangkj.com/tush/xpkg/utils"
) )
......
...@@ -10,11 +10,11 @@ import ( ...@@ -10,11 +10,11 @@ import (
"github.com/dgraph-io/ristretto" "github.com/dgraph-io/ristretto"
"github.com/spf13/cast" "github.com/spf13/cast"
"gitlab.wanzhuangkj.com/tush/xpkg/encoding" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
ctxUtil "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils" ctxUtil "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
xslice "gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils" xslice "gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
) )
type memoryCache struct { type memoryCache struct {
......
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"gitlab.wanzhuangkj.com/tush/xpkg/gotest" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/gotest"
"gitlab.wanzhuangkj.com/tush/xpkg/utils" "gitlab.wanzhuangkj.com/tush/xpkg/utils"
) )
......
...@@ -10,8 +10,8 @@ import ( ...@@ -10,8 +10,8 @@ import (
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
"gitlab.wanzhuangkj.com/tush/xpkg/encoding" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
) )
// CacheNotFound no hit cache // CacheNotFound no hit cache
......
...@@ -6,8 +6,8 @@ import ( ...@@ -6,8 +6,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"gitlab.wanzhuangkj.com/tush/xpkg/encoding" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
"gitlab.wanzhuangkj.com/tush/xpkg/gotest" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/gotest"
"gitlab.wanzhuangkj.com/tush/xpkg/utils" "gitlab.wanzhuangkj.com/tush/xpkg/utils"
) )
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"github.com/mojocn/base64Captcha" "github.com/mojocn/base64Captcha"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
) )
const ( const (
......
...@@ -4,9 +4,10 @@ import ( ...@@ -4,9 +4,10 @@ import (
"crypto/rand" "crypto/rand"
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"math/big" "math/big"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gopkg.in/gomail.v2" "gopkg.in/gomail.v2"
) )
......
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
"google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"gitlab.wanzhuangkj.com/tush/xpkg/encoding" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
) )
// Name is the name registered for the json codec. // Name is the name registered for the json codec.
......
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"gitlab.wanzhuangkj.com/tush/xpkg/encoding" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/encoding"
) )
// Name is the name registered for the proto compressor. // Name is the name registered for the proto compressor.
......
...@@ -3,6 +3,7 @@ package eventbus ...@@ -3,6 +3,7 @@ package eventbus
var Eb = New() var Eb = New()
const ( const (
TopicParseConfStart string = "event:application:conf:init:start" // 配置文件解析开始
TopicParseConfFinish string = "event:application:conf:init:finish" // 配置文件解析完毕 TopicParseConfFinish string = "event:application:conf:init:finish" // 配置文件解析完毕
TopicDBInitFinish string = "event:application:database:init:finish" // 数据库连接初始化完成 TopicDBInitFinish string = "event:application:database:init:finish" // 数据库连接初始化完成
TopicCacheInitFinish string = "event:application:cache:init:finish" // cache初始化完成 TopicCacheInitFinish string = "event:application:cache:init:finish" // cache初始化完成
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"runtime" "runtime"
"time" "time"
"gitlab.wanzhuangkj.com/tush/xpkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
ctxUtil "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils" ctxUtil "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
......
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
"github.com/DATA-DOG/go-sqlmock" "github.com/DATA-DOG/go-sqlmock"
"gorm.io/gorm" "gorm.io/gorm"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm/query" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/sgorm/query"
) )
func TestNewDao(t *testing.T) { func TestNewDao(t *testing.T) {
......
...@@ -13,12 +13,12 @@ import ( ...@@ -13,12 +13,12 @@ import (
"strings" "strings"
"time" "time"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli/entity" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli/entity"
"gitlab.wanzhuangkj.com/tush/xpkg/httpcli/httpContentType" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/httpcli/httpContentType"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"github.com/duke-git/lancet/v2/retry" "github.com/duke-git/lancet/v2/retry"
"gitlab.wanzhuangkj.com/tush/xpkg/logger" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils" "gitlab.wanzhuangkj.com/tush/xpkg/utils/ctxUtils"
) )
......
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论