mirror of https://github.com/zhufuyi/sponge
update to go-redis v9
This commit is contained in:
parent
6a86d91ecb
commit
1b03b3c8ed
|
@ -51,14 +51,6 @@ func InitApp() {
|
|||
logger.Debug(config.Show())
|
||||
logger.Info("[logger] was initialized")
|
||||
|
||||
// initializing database
|
||||
model.InitDB()
|
||||
logger.Infof("[%s] was initialized", cfg.Database.Driver)
|
||||
model.InitCache(cfg.App.CacheType)
|
||||
if cfg.App.CacheType != "" {
|
||||
logger.Infof("[%s] was initialized", cfg.App.CacheType)
|
||||
}
|
||||
|
||||
// initializing tracing
|
||||
if cfg.App.EnableTrace {
|
||||
tracer.InitWithConfig(
|
||||
|
@ -80,6 +72,14 @@ func InitApp() {
|
|||
)
|
||||
logger.Info("[resource statistics] was initialized")
|
||||
}
|
||||
|
||||
// initializing database
|
||||
model.InitDB()
|
||||
logger.Infof("[%s] was initialized", cfg.Database.Driver)
|
||||
model.InitCache(cfg.App.CacheType)
|
||||
if cfg.App.CacheType != "" {
|
||||
logger.Infof("[%s] was initialized", cfg.App.CacheType)
|
||||
}
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
|
|
|
@ -64,10 +64,6 @@ func InitApp() {
|
|||
logger.Info("[tracer] was initialized")
|
||||
}
|
||||
|
||||
// initializing the rpc server connection
|
||||
// example:
|
||||
//rpcclient.NewServerNameExampleRPCConn()
|
||||
|
||||
// initializing the print system and process resources
|
||||
if cfg.App.EnableStat {
|
||||
stat.Init(
|
||||
|
@ -76,6 +72,10 @@ func InitApp() {
|
|||
)
|
||||
logger.Info("[resource statistics] was initialized")
|
||||
}
|
||||
|
||||
// initializing the rpc server connection
|
||||
// example:
|
||||
//rpcclient.NewServerNameExampleRPCConn()
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
|
|
|
@ -51,14 +51,6 @@ func InitApp() {
|
|||
logger.Debug(config.Show())
|
||||
logger.Info("[logger] was initialized")
|
||||
|
||||
// initializing database
|
||||
//model.InitDB()
|
||||
//logger.Infof("[%s] was initialized", cfg.Database.Driver)
|
||||
//model.InitCache(cfg.App.CacheType)
|
||||
//if cfg.App.CacheType != "" {
|
||||
// logger.Infof("[%s] was initialized", cfg.App.CacheType)
|
||||
//}
|
||||
|
||||
// initializing tracing
|
||||
if cfg.App.EnableTrace {
|
||||
tracer.InitWithConfig(
|
||||
|
@ -80,6 +72,14 @@ func InitApp() {
|
|||
)
|
||||
logger.Info("[resource statistics] was initialized")
|
||||
}
|
||||
|
||||
// initializing database
|
||||
//model.InitDB()
|
||||
//logger.Infof("[%s] was initialized", cfg.Database.Driver)
|
||||
//model.InitCache(cfg.App.CacheType)
|
||||
//if cfg.App.CacheType != "" {
|
||||
// logger.Infof("[%s] was initialized", cfg.App.CacheType)
|
||||
//}
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
|
|
|
@ -51,14 +51,6 @@ func InitApp() {
|
|||
logger.Debug(config.Show())
|
||||
logger.Info("[logger] was initialized")
|
||||
|
||||
// initializing database
|
||||
//model.InitDB()
|
||||
//logger.Infof("[%s] was initialized", cfg.Database.Driver)
|
||||
//model.InitCache(cfg.App.CacheType)
|
||||
//if cfg.App.CacheType != "" {
|
||||
// logger.Infof("[%s] was initialized", cfg.App.CacheType)
|
||||
//}
|
||||
|
||||
// initializing tracing
|
||||
if cfg.App.EnableTrace {
|
||||
tracer.InitWithConfig(
|
||||
|
@ -80,6 +72,14 @@ func InitApp() {
|
|||
)
|
||||
logger.Info("[resource statistics] was initialized")
|
||||
}
|
||||
|
||||
// initializing database
|
||||
//model.InitDB()
|
||||
//logger.Infof("[%s] was initialized", cfg.Database.Driver)
|
||||
//model.InitCache(cfg.App.CacheType)
|
||||
//if cfg.App.CacheType != "" {
|
||||
// logger.Infof("[%s] was initialized", cfg.App.CacheType)
|
||||
//}
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
|
|
|
@ -51,14 +51,6 @@ func InitApp() {
|
|||
logger.Debug(config.Show())
|
||||
logger.Info("[logger] was initialized")
|
||||
|
||||
// initializing database
|
||||
model.InitDB()
|
||||
logger.Infof("[%s] was initialized", cfg.Database.Driver)
|
||||
model.InitCache(cfg.App.CacheType)
|
||||
if cfg.App.CacheType != "" {
|
||||
logger.Infof("[%s] was initialized", cfg.App.CacheType)
|
||||
}
|
||||
|
||||
// initializing tracing
|
||||
if cfg.App.EnableTrace {
|
||||
tracer.InitWithConfig(
|
||||
|
@ -80,6 +72,14 @@ func InitApp() {
|
|||
)
|
||||
logger.Info("[resource statistics] was initialized")
|
||||
}
|
||||
|
||||
// initializing database
|
||||
model.InitDB()
|
||||
logger.Infof("[%s] was initialized", cfg.Database.Driver)
|
||||
model.InitCache(cfg.App.CacheType)
|
||||
if cfg.App.CacheType != "" {
|
||||
logger.Infof("[%s] was initialized", cfg.App.CacheType)
|
||||
}
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
|
|
|
@ -51,14 +51,6 @@ func InitApp() {
|
|||
logger.Debug(config.Show())
|
||||
logger.Info("[logger] was initialized")
|
||||
|
||||
// initializing database
|
||||
//model.InitDB()
|
||||
//logger.Infof("[%s] was initialized", cfg.Database.Driver)
|
||||
//model.InitCache(cfg.App.CacheType)
|
||||
//if cfg.App.CacheType != "" {
|
||||
// logger.Infof("[%s] was initialized", cfg.App.CacheType)
|
||||
//}
|
||||
|
||||
// initializing tracing
|
||||
if cfg.App.EnableTrace {
|
||||
tracer.InitWithConfig(
|
||||
|
@ -80,6 +72,14 @@ func InitApp() {
|
|||
)
|
||||
logger.Info("[resource statistics] was initialized")
|
||||
}
|
||||
|
||||
// initializing database
|
||||
//model.InitDB()
|
||||
//logger.Infof("[%s] was initialized", cfg.Database.Driver)
|
||||
//model.InitCache(cfg.App.CacheType)
|
||||
//if cfg.App.CacheType != "" {
|
||||
// logger.Infof("[%s] was initialized", cfg.App.CacheType)
|
||||
//}
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
|
|
|
@ -51,14 +51,6 @@ func InitApp() {
|
|||
logger.Debug(config.Show())
|
||||
logger.Info("[logger] was initialized")
|
||||
|
||||
// initializing database
|
||||
model.InitDB()
|
||||
logger.Infof("[%s] was initialized", cfg.Database.Driver)
|
||||
model.InitCache(cfg.App.CacheType)
|
||||
if cfg.App.CacheType != "" {
|
||||
logger.Infof("[%s] was initialized", cfg.App.CacheType)
|
||||
}
|
||||
|
||||
// initializing tracing
|
||||
if cfg.App.EnableTrace {
|
||||
tracer.InitWithConfig(
|
||||
|
@ -80,6 +72,14 @@ func InitApp() {
|
|||
)
|
||||
logger.Info("[resource statistics] was initialized")
|
||||
}
|
||||
|
||||
// initializing database
|
||||
model.InitDB()
|
||||
logger.Infof("[%s] was initialized", cfg.Database.Driver)
|
||||
model.InitCache(cfg.App.CacheType)
|
||||
if cfg.App.CacheType != "" {
|
||||
logger.Infof("[%s] was initialized", cfg.App.CacheType)
|
||||
}
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
|
|
10
go.mod
10
go.mod
|
@ -1,6 +1,6 @@
|
|||
module github.com/zhufuyi/sponge
|
||||
|
||||
go 1.19
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0
|
||||
|
@ -9,13 +9,12 @@ require (
|
|||
github.com/blastrain/vitess-sqlparser v0.0.0-20201030050434-a139afbb1aba
|
||||
github.com/bojand/ghz v0.117.0
|
||||
github.com/dgraph-io/ristretto v0.1.1
|
||||
github.com/fatih/color v1.13.0
|
||||
github.com/felixge/fgprof v0.9.3
|
||||
github.com/fsnotify/fsnotify v1.5.4
|
||||
github.com/gin-contrib/cors v1.3.1
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
github.com/go-playground/validator/v10 v10.14.0
|
||||
github.com/go-redis/redis/extra/redisotel v0.3.0
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
github.com/go-sql-driver/mysql v1.7.0
|
||||
github.com/golang-jwt/jwt/v5 v5.0.0
|
||||
github.com/golang/snappy v0.0.4
|
||||
|
@ -31,6 +30,8 @@ require (
|
|||
github.com/pkg/errors v0.9.1
|
||||
github.com/prometheus/client_golang v1.13.0
|
||||
github.com/rabbitmq/amqp091-go v1.9.0
|
||||
github.com/redis/go-redis/extra/redisotel/v9 v9.5.3
|
||||
github.com/redis/go-redis/v9 v9.6.1
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/shirou/gopsutil/v3 v3.23.8
|
||||
github.com/spf13/cobra v1.4.0
|
||||
|
@ -98,7 +99,6 @@ require (
|
|||
github.com/eapache/queue v1.1.0 // indirect
|
||||
github.com/envoyproxy/go-control-plane v0.11.1 // indirect
|
||||
github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect
|
||||
github.com/fatih/color v1.13.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-logr/logr v1.4.1 // indirect
|
||||
|
@ -110,7 +110,6 @@ require (
|
|||
github.com/go-openapi/swag v0.19.15 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-redis/redis/extra/rediscmd v0.2.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/glog v1.1.2 // indirect
|
||||
|
@ -172,6 +171,7 @@ require (
|
|||
github.com/prometheus/common v0.37.0 // indirect
|
||||
github.com/prometheus/procfs v0.8.0 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/redis/go-redis/extra/rediscmd/v9 v9.5.3 // indirect
|
||||
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
||||
github.com/shopspring/decimal v1.2.0 // indirect
|
||||
github.com/spf13/afero v1.9.2 // indirect
|
||||
|
|
53
go.sum
53
go.sum
|
@ -92,6 +92,8 @@ github.com/blastrain/vitess-sqlparser v0.0.0-20201030050434-a139afbb1aba h1:hBK2
|
|||
github.com/blastrain/vitess-sqlparser v0.0.0-20201030050434-a139afbb1aba/go.mod h1:FGQp+RNQwVmLzDq6HBrYCww9qJQyNwH9Qji/quTQII4=
|
||||
github.com/bojand/ghz v0.117.0 h1:dTMxg+tUcLMw8BYi7vQPjXsrM2DJ20ns53hz1am1SbQ=
|
||||
github.com/bojand/ghz v0.117.0/go.mod h1:MXspmKdJie7NAS0IHzqG9X5h6zO3tIRGQ6Tkt8sAwa4=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
|
||||
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
|
||||
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
||||
|
@ -171,8 +173,6 @@ github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
|
|||
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
|
||||
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
|
||||
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
|
||||
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
|
||||
|
@ -229,14 +229,6 @@ github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91
|
|||
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
|
||||
github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js=
|
||||
github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
||||
github.com/go-redis/redis/extra/rediscmd v0.2.0 h1:A3bhCsCKsedClEH9/jYlcKqOuBoeeV+H0yDie5t+a6w=
|
||||
github.com/go-redis/redis/extra/rediscmd v0.2.0/go.mod h1:Z5bP1EHl9PvWhx/DupfCdZwB0JgOO3aVxWc/PFux+BE=
|
||||
github.com/go-redis/redis/extra/redisotel v0.3.0 h1:8rrizwFAUUeMgmelyiQi9KeFwmpQhay9E+/rE6qHsBM=
|
||||
github.com/go-redis/redis/extra/redisotel v0.3.0/go.mod h1:sGV3dQnPMBUuqzowEP2nZPhLXCMeh83nY64yaju249c=
|
||||
github.com/go-redis/redis/v8 v8.3.2/go.mod h1:jszGxBCez8QA1HWSmQxJO9Y82kNibbUmeYhKWrBejTU=
|
||||
github.com/go-redis/redis/v8 v8.5.0/go.mod h1:YmEcgBDttjnkbMzDAhDtQxY9yVA7jMN6PCR5HeMvqFE=
|
||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
|
||||
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||
|
@ -382,7 +374,6 @@ github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOn
|
|||
github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4=
|
||||
github.com/hashicorp/serf v0.9.7 h1:hkdgbqizGQHuU5IPqYM1JdSMV8nKfpuOnZYXssk9muY=
|
||||
github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||
github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
|
||||
github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||
|
@ -532,18 +523,6 @@ github.com/nacos-group/nacos-sdk-go/v2 v2.1.0/go.mod h1:ys/1adWeKXXzbNWfRNbaFlX/
|
|||
github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM=
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
|
||||
github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
|
||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U=
|
||||
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
|
||||
|
@ -607,6 +586,12 @@ github.com/rabbitmq/amqp091-go v1.9.0 h1:qrQtyzB4H8BQgEuJwhmVQqVHB9O4+MNDJCCAcpc
|
|||
github.com/rabbitmq/amqp091-go v1.9.0/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/redis/go-redis/extra/rediscmd/v9 v9.5.3 h1:1/BDligzCa40GTllkDnY3Y5DTHuKCONbB2JcRyIfl20=
|
||||
github.com/redis/go-redis/extra/rediscmd/v9 v9.5.3/go.mod h1:3dZmcLn3Qw6FLlWASn1g4y+YO9ycEFUOM+bhBmzLVKQ=
|
||||
github.com/redis/go-redis/extra/redisotel/v9 v9.5.3 h1:kuvuJL/+MZIEdvtb/kTBRiRgYaOmx1l+lYJyVdrRUOs=
|
||||
github.com/redis/go-redis/extra/redisotel/v9 v9.5.3/go.mod h1:7f/FMrf5RRRVHXgfk7CzSVzXHiWeuOQUu2bsVqWoa+g=
|
||||
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
|
||||
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
|
@ -732,22 +717,16 @@ go.opentelemetry.io/contrib v1.24.0 h1:Tfn7pP/482iIzeeba91tP52a1c1TEeqYc1saih+vB
|
|||
go.opentelemetry.io/contrib v1.24.0/go.mod h1:usW9bPlrjHiJFbK0a6yK/M5wNHs3nLmtrT3vzhoD3co=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0=
|
||||
go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY=
|
||||
go.opentelemetry.io/otel v0.16.0/go.mod h1:e4GKElweB8W2gWUqbghw0B8t5MCTccc9212eNHnOHwA=
|
||||
go.opentelemetry.io/otel v0.17.0/go.mod h1:Oqtdxmf7UtEvL037ohlgnaYa1h7GtMh0NcSd9eqkC9s=
|
||||
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
|
||||
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4=
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0/go.mod h1:nPCqOnEH9rNLKqH/+rrUjiMzHJdV1BlpKcTwRTyKkKI=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 h1:s0PHtIkN+3xrbDOpt2M8OTG92cWqUESvzh2MxiR5xY8=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0/go.mod h1:hZlFbDbRt++MMPCCfSJfmhkGIWnX1h3XjkfxZUjLrIA=
|
||||
go.opentelemetry.io/otel/metric v0.17.0/go.mod h1:hUz9lH1rNXyEwWAhIWCMFWKhYtpASgSnObJFnU26dJ0=
|
||||
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
|
||||
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
|
||||
go.opentelemetry.io/otel/oteltest v0.17.0/go.mod h1:JT/LGFxPwpN+nlsTiinSYjdIx3hZIGqHCpChcIZmdoE=
|
||||
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
|
||||
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
|
||||
go.opentelemetry.io/otel/trace v0.17.0/go.mod h1:bIujpqg6ZL6xUTubIUgziI1jSaUPthmabA/ygf/6Cfg=
|
||||
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
|
||||
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
|
@ -823,7 +802,6 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91
|
|||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
|
@ -847,15 +825,12 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/
|
|||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
|
@ -903,7 +878,6 @@ golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
|||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
|
@ -917,15 +891,12 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
@ -942,7 +913,6 @@ golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
@ -953,7 +923,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
@ -1056,7 +1025,6 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u
|
|||
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
|
@ -1181,8 +1149,6 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
|
|||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
|
@ -1193,7 +1159,6 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8
|
|||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
|
||||
gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
|
||||
gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
|
@ -1203,8 +1168,6 @@ gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3
|
|||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
|
@ -136,8 +136,8 @@ func (h *userExampleHandler) UpdateByID(c *gin.Context) {
|
|||
response.Error(c, ecode.ErrUpdateByIDUserExample)
|
||||
return
|
||||
}
|
||||
userExample.ID = oid
|
||||
// Note: if copier.Copy cannot assign a value to a field, add it here
|
||||
userExample.ID = oid
|
||||
|
||||
ctx := middleware.WrapCtx(c)
|
||||
err = h.iDao.UpdateByID(ctx, userExample)
|
||||
|
|
|
@ -142,8 +142,8 @@ func (h *userExampleHandler) UpdateByID(c *gin.Context) {
|
|||
response.Error(c, ecode.ErrUpdateByIDUserExample)
|
||||
return
|
||||
}
|
||||
userExample.ID = oid
|
||||
// Note: if copier.Copy cannot assign a value to a field, add it here
|
||||
userExample.ID = oid
|
||||
|
||||
ctx := middleware.WrapCtx(c)
|
||||
err = h.iDao.UpdateByID(ctx, userExample)
|
||||
|
|
|
@ -6,12 +6,13 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/zhufuyi/sponge/pkg/ggorm"
|
||||
"github.com/zhufuyi/sponge/pkg/goredis"
|
||||
"github.com/zhufuyi/sponge/pkg/logger"
|
||||
"github.com/zhufuyi/sponge/pkg/tracer"
|
||||
"github.com/zhufuyi/sponge/pkg/utils"
|
||||
|
||||
"github.com/zhufuyi/sponge/internal/config"
|
||||
|
@ -72,7 +73,7 @@ func InitRedis() {
|
|||
goredis.WithWriteTimeout(time.Duration(config.Get().Redis.WriteTimeout) * time.Second),
|
||||
}
|
||||
if config.Get().App.EnableTrace {
|
||||
opts = append(opts, goredis.WithEnableTrace())
|
||||
opts = append(opts, goredis.WithTracing(tracer.GetProvider()))
|
||||
}
|
||||
|
||||
var err error
|
||||
|
|
|
@ -5,12 +5,13 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
|
||||
"github.com/zhufuyi/sponge/pkg/goredis"
|
||||
"github.com/zhufuyi/sponge/pkg/mgo"
|
||||
"github.com/zhufuyi/sponge/pkg/tracer"
|
||||
"github.com/zhufuyi/sponge/pkg/utils"
|
||||
|
||||
"github.com/zhufuyi/sponge/internal/config"
|
||||
|
@ -74,7 +75,7 @@ func InitRedis() {
|
|||
goredis.WithWriteTimeout(time.Duration(config.Get().Redis.WriteTimeout) * time.Second),
|
||||
}
|
||||
if config.Get().App.EnableTrace {
|
||||
opts = append(opts, goredis.WithEnableTrace())
|
||||
opts = append(opts, goredis.WithTracing(tracer.GetProvider()))
|
||||
}
|
||||
|
||||
var err error
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/zhufuyi/sponge/pkg/encoding"
|
||||
)
|
||||
|
@ -209,3 +209,182 @@ func BuildCacheKey(keyPrefix string, key string) (string, error) {
|
|||
|
||||
return cacheKey, nil
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------
|
||||
|
||||
// redisClusterCache redis cluster cache object
|
||||
type redisClusterCache struct {
|
||||
client *redis.ClusterClient
|
||||
KeyPrefix string
|
||||
encoding encoding.Encoding
|
||||
DefaultExpireTime time.Duration
|
||||
newObject func() interface{}
|
||||
}
|
||||
|
||||
// NewRedisClusterCache new a cache
|
||||
func NewRedisClusterCache(client *redis.ClusterClient, keyPrefix string, encode encoding.Encoding, newObject func() interface{}) Cache {
|
||||
return &redisClusterCache{
|
||||
client: client,
|
||||
KeyPrefix: keyPrefix,
|
||||
encoding: encode,
|
||||
newObject: newObject,
|
||||
}
|
||||
}
|
||||
|
||||
// Set one value
|
||||
func (c *redisClusterCache) Set(ctx context.Context, key string, val interface{}, expiration time.Duration) error {
|
||||
buf, err := encoding.Marshal(c.encoding, val)
|
||||
if err != nil {
|
||||
return fmt.Errorf("encoding.Marshal error: %v, key=%s, val=%+v ", err, key, val)
|
||||
}
|
||||
|
||||
cacheKey, err := BuildCacheKey(c.KeyPrefix, key)
|
||||
if err != nil {
|
||||
return fmt.Errorf("BuildCacheKey error: %v, key=%s", err, key)
|
||||
}
|
||||
//if expiration == 0 {
|
||||
// expiration = DefaultExpireTime
|
||||
//}
|
||||
err = c.client.Set(ctx, cacheKey, buf, expiration).Err()
|
||||
if err != nil {
|
||||
return fmt.Errorf("c.client.Set error: %v, cacheKey=%s", err, cacheKey)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get one value
|
||||
func (c *redisClusterCache) Get(ctx context.Context, key string, val interface{}) error {
|
||||
cacheKey, err := BuildCacheKey(c.KeyPrefix, key)
|
||||
if err != nil {
|
||||
return fmt.Errorf("BuildCacheKey error: %v, key=%s", err, key)
|
||||
}
|
||||
|
||||
bytes, err := c.client.Get(ctx, cacheKey).Bytes()
|
||||
// NOTE: don't handle the case where redis value is nil
|
||||
// but leave it to the upstream for processing
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// prevent Unmarshal from reporting an error if data is empty
|
||||
if string(bytes) == "" {
|
||||
return nil
|
||||
}
|
||||
if string(bytes) == NotFoundPlaceholder {
|
||||
return ErrPlaceholder
|
||||
}
|
||||
err = encoding.Unmarshal(c.encoding, bytes, val)
|
||||
if err != nil {
|
||||
return fmt.Errorf("encoding.Unmarshal error: %v, key=%s, cacheKey=%s, type=%v, json=%+v ",
|
||||
err, key, cacheKey, reflect.TypeOf(val), string(bytes))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MultiSet set multiple values
|
||||
func (c *redisClusterCache) MultiSet(ctx context.Context, valueMap map[string]interface{}, expiration time.Duration) error {
|
||||
if len(valueMap) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// the key-value is paired and has twice the capacity of a map
|
||||
paris := make([]interface{}, 0, 2*len(valueMap))
|
||||
for key, value := range valueMap {
|
||||
buf, err := encoding.Marshal(c.encoding, value)
|
||||
if err != nil {
|
||||
fmt.Printf("encoding.Marshal error, %v, value:%v\n", err, value)
|
||||
continue
|
||||
}
|
||||
cacheKey, err := BuildCacheKey(c.KeyPrefix, key)
|
||||
if err != nil {
|
||||
fmt.Printf("BuildCacheKey error, %v, key:%v\n", err, key)
|
||||
continue
|
||||
}
|
||||
paris = append(paris, []byte(cacheKey))
|
||||
paris = append(paris, buf)
|
||||
}
|
||||
pipeline := c.client.Pipeline()
|
||||
err := pipeline.MSet(ctx, paris...).Err()
|
||||
if err != nil {
|
||||
return fmt.Errorf("pipeline.MSet error: %v", err)
|
||||
}
|
||||
for i := 0; i < len(paris); i = i + 2 {
|
||||
switch paris[i].(type) {
|
||||
case []byte:
|
||||
pipeline.Expire(ctx, string(paris[i].([]byte)), expiration)
|
||||
default:
|
||||
fmt.Printf("redis expire is unsupported key type: %+v\n", reflect.TypeOf(paris[i]))
|
||||
}
|
||||
}
|
||||
_, err = pipeline.Exec(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("pipeline.Exec error: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MultiGet get multiple values
|
||||
func (c *redisClusterCache) MultiGet(ctx context.Context, keys []string, value interface{}) error {
|
||||
if len(keys) == 0 {
|
||||
return nil
|
||||
}
|
||||
cacheKeys := make([]string, len(keys))
|
||||
for index, key := range keys {
|
||||
cacheKey, err := BuildCacheKey(c.KeyPrefix, key)
|
||||
if err != nil {
|
||||
return fmt.Errorf("BuildCacheKey error: %v, key=%s", err, key)
|
||||
}
|
||||
cacheKeys[index] = cacheKey
|
||||
}
|
||||
values, err := c.client.MGet(ctx, cacheKeys...).Result()
|
||||
if err != nil {
|
||||
return fmt.Errorf("c.client.MGet error: %v, keys=%+v", err, cacheKeys)
|
||||
}
|
||||
|
||||
// Injection into map via reflection
|
||||
valueMap := reflect.ValueOf(value)
|
||||
for i, v := range values {
|
||||
if v == nil {
|
||||
continue
|
||||
}
|
||||
object := c.newObject()
|
||||
err = encoding.Unmarshal(c.encoding, []byte(v.(string)), object)
|
||||
if err != nil {
|
||||
fmt.Printf("unmarshal data error: %+v, key=%s, cacheKey=%s type=%v\n", err, keys[i], cacheKeys[i], reflect.TypeOf(value))
|
||||
continue
|
||||
}
|
||||
valueMap.SetMapIndex(reflect.ValueOf(cacheKeys[i]), reflect.ValueOf(object))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Del delete multiple values
|
||||
func (c *redisClusterCache) Del(ctx context.Context, keys ...string) error {
|
||||
if len(keys) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
cacheKeys := make([]string, len(keys))
|
||||
for index, key := range keys {
|
||||
cacheKey, err := BuildCacheKey(c.KeyPrefix, key)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
cacheKeys[index] = cacheKey
|
||||
}
|
||||
err := c.client.Del(ctx, cacheKeys...).Err()
|
||||
if err != nil {
|
||||
return fmt.Errorf("c.client.Del error: %v, keys=%+v", err, cacheKeys)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetCacheWithNotFound set value for notfound
|
||||
func (c *redisClusterCache) SetCacheWithNotFound(ctx context.Context, key string) error {
|
||||
cacheKey, err := BuildCacheKey(c.KeyPrefix, key)
|
||||
if err != nil {
|
||||
return fmt.Errorf("BuildCacheKey error: %v, key=%s", err, key)
|
||||
}
|
||||
|
||||
return c.client.Set(ctx, cacheKey, NotFoundPlaceholder, DefaultNotFoundExpireTime).Err()
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ type redisUser struct {
|
|||
Name string
|
||||
}
|
||||
|
||||
func newRedisCache() *gotest.Cache {
|
||||
func newTestData() map[string]interface{} {
|
||||
record1 := &redisUser{
|
||||
ID: 1,
|
||||
Name: "foo",
|
||||
|
@ -26,11 +26,14 @@ func newRedisCache() *gotest.Cache {
|
|||
Name: "bar",
|
||||
}
|
||||
|
||||
testData := map[string]interface{}{
|
||||
return map[string]interface{}{
|
||||
utils.Uint64ToStr(record1.ID): record1,
|
||||
utils.Uint64ToStr(record2.ID): record2,
|
||||
}
|
||||
}
|
||||
|
||||
func newRedisCache() *gotest.Cache {
|
||||
testData := newTestData()
|
||||
c := gotest.NewCache(testData)
|
||||
cachePrefix := ""
|
||||
c.ICache = NewRedisCache(c.RedisClient, cachePrefix, encoding.JSONEncoding{}, func() interface{} {
|
||||
|
@ -40,6 +43,17 @@ func newRedisCache() *gotest.Cache {
|
|||
return c
|
||||
}
|
||||
|
||||
func newRedisClusterCache() *gotest.RCCache {
|
||||
testData := newTestData()
|
||||
c := gotest.NewRCCache(testData)
|
||||
cachePrefix := ""
|
||||
c.ICache = NewRedisClusterCache(c.RedisClient, cachePrefix, encoding.JSONEncoding{}, func() interface{} {
|
||||
return &redisUser{}
|
||||
})
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func TestRedisCache(t *testing.T) {
|
||||
c := newRedisCache()
|
||||
defer c.Close()
|
||||
|
@ -121,6 +135,83 @@ func TestRedisCacheError(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestRedisClusterCache(t *testing.T) {
|
||||
c := newRedisClusterCache()
|
||||
defer c.Close()
|
||||
testData := c.TestDataSlice[0].(*redisUser)
|
||||
iCache := c.ICache.(Cache)
|
||||
|
||||
key := utils.Uint64ToStr(testData.ID)
|
||||
err := iCache.Set(c.Ctx, key, c.TestDataMap[key], time.Minute)
|
||||
assert.NoError(t, err)
|
||||
|
||||
val := &redisUser{}
|
||||
err = iCache.Get(c.Ctx, key, val)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, testData.Name, val.Name)
|
||||
|
||||
err = iCache.Del(c.Ctx, key)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = iCache.MultiSet(c.Ctx, c.TestDataMap, time.Minute)
|
||||
assert.NoError(t, err)
|
||||
|
||||
var keys []string
|
||||
for k := range c.TestDataMap {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
vals := make(map[string]*redisUser)
|
||||
err = iCache.MultiGet(c.Ctx, keys, vals)
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, len(c.TestDataSlice), len(vals))
|
||||
err = iCache.SetCacheWithNotFound(c.Ctx, "not_found")
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestRedisClusterCacheError(t *testing.T) {
|
||||
c := newRedisClusterCache()
|
||||
defer c.Close()
|
||||
testData := c.TestDataSlice[0].(*redisUser)
|
||||
iCache := c.ICache.(Cache)
|
||||
|
||||
// Set empty key error test
|
||||
key := utils.Uint64ToStr(testData.ID)
|
||||
err := iCache.Set(c.Ctx, "", c.TestDataMap[key], time.Minute)
|
||||
assert.Error(t, err)
|
||||
|
||||
// Set empty value error test
|
||||
key = utils.Uint64ToStr(testData.ID)
|
||||
err = iCache.Set(c.Ctx, key, nil, time.Minute)
|
||||
assert.Error(t, err)
|
||||
|
||||
// Get empty key error test
|
||||
val := &redisUser{}
|
||||
err = iCache.Get(c.Ctx, "", val)
|
||||
assert.Error(t, err)
|
||||
|
||||
// Get empty result test
|
||||
key = utils.Uint64ToStr(testData.ID)
|
||||
err = iCache.Get(c.Ctx, key, val)
|
||||
assert.Error(t, err)
|
||||
|
||||
// Get result error test
|
||||
key = utils.Uint64ToStr(testData.ID)
|
||||
_ = iCache.Set(c.Ctx, key, c.TestDataMap[key], time.Minute)
|
||||
time.Sleep(time.Millisecond)
|
||||
err = iCache.Get(c.Ctx, key, nil)
|
||||
assert.Error(t, err)
|
||||
|
||||
_ = iCache.MultiSet(c.Ctx, nil, time.Minute)
|
||||
_ = iCache.MultiGet(c.Ctx, nil, time.Minute)
|
||||
|
||||
// Del empty key error test
|
||||
err = iCache.Del(c.Ctx)
|
||||
assert.NoError(t, err)
|
||||
err = iCache.Del(c.Ctx, "")
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestBuildCacheKey(t *testing.T) {
|
||||
_, err := BuildCacheKey("", "")
|
||||
assert.Error(t, err)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
## goredis
|
||||
|
||||
`goredis` library wrapped in [go-redis](github.com/go-redis/redis).
|
||||
`goredis` library wrapped in [go-redis](https://github.com/redis/go-redis).
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -10,13 +10,13 @@
|
|||
|
||||
```go
|
||||
// way 1: redis version 6.0 or above
|
||||
redisCli, err := goredis.Init("default:123456@127.0.0.1:6379", goredis.WithEnableTrace())
|
||||
redisCli, err := goredis.Init("default:123456@127.0.0.1:6379") // can set parameters such as timeout, tls, tracing, such as goredis.Withxxx()
|
||||
if err != nil {
|
||||
panic("goredis.Init error: " + err.Error())
|
||||
}
|
||||
|
||||
// way 2: redis version 5.0 or below
|
||||
redisCli := goredis.Init2("127.0.0.1:6379", "123456", 0, goredis.WithEnableTrace())
|
||||
redisCli, err := goredis.InitSingle("127.0.0.1:6379", "123456", 0) // can set parameters such as timeout, tls, tracing, such as goredis.Withxxx()
|
||||
```
|
||||
|
||||
<br>
|
||||
|
@ -24,8 +24,8 @@
|
|||
#### Sentinel
|
||||
|
||||
```go
|
||||
addrs := []string{"127.0.0.1:6380", "127.0.0.1:6381", "127.0.0.1:6382"}
|
||||
rdb := goredis.InitSentinel("master", addrs, "default", "123456", goredis.WithEnableTrace())
|
||||
addrs := []string{"127.0.0.1:6380", "127.0.0.1:6381", "127.0.0.1:6382","127.0.0.1:26380", "127.0.0.1:26381", "127.0.0.1:26382"}
|
||||
rdbCli, err : := goredis.InitSentinel("mymaster", addrs, "", "123456") // can set parameters such as timeout, tls, tracing, such as goredis.Withxxx()
|
||||
```
|
||||
|
||||
<br>
|
||||
|
@ -33,8 +33,8 @@
|
|||
#### Cluster
|
||||
|
||||
```go
|
||||
addrs := []string{"127.0.0.1:6380", "127.0.0.1:6381", "127.0.0.1:6382"}
|
||||
clusterRdb := goredis.InitCluster(addrs, "default", "123456", goredis.WithEnableTrace())
|
||||
addrs := []string{"127.0.0.1:6380", "127.0.0.1:6381", "127.0.0.1:6382","127.0.0.1:6383", "127.0.0.1:6384", "127.0.0.1:6385"}
|
||||
clusterRdb, err : := goredis.InitCluster(addrs, "", "123456") // can set parameters such as timeout, tls, tracing, such as goredis.Withxxx()
|
||||
```
|
||||
|
||||
<br>
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
package goredis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-redis/redis/extra/redisotel"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/redis/go-redis/extra/redisotel/v9"
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -30,13 +32,132 @@ func Init(dsn string, opts ...Option) (*redis.Client, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
rdb := redis.NewClient(opt)
|
||||
|
||||
if o.enableTrace {
|
||||
rdb.AddHook(redisotel.TracingHook{})
|
||||
// replace single options if provided
|
||||
if o.singleOptions != nil {
|
||||
opt = o.singleOptions
|
||||
}
|
||||
|
||||
return rdb, nil
|
||||
rdb := redis.NewClient(opt)
|
||||
|
||||
if o.tracerProvider != nil {
|
||||
err = redisotel.InstrumentTracing(rdb, redisotel.WithTracerProvider(o.tracerProvider))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), 15*time.Second) //nolint
|
||||
err = rdb.Ping(ctx).Err()
|
||||
|
||||
return rdb, err
|
||||
}
|
||||
|
||||
// InitSingle connecting to single redis instance
|
||||
func InitSingle(addr string, password string, db int, opts ...Option) (*redis.Client, error) {
|
||||
o := defaultOptions()
|
||||
o.apply(opts...)
|
||||
|
||||
opt := &redis.Options{
|
||||
Addr: addr,
|
||||
Password: password,
|
||||
DB: db,
|
||||
DialTimeout: o.dialTimeout,
|
||||
ReadTimeout: o.readTimeout,
|
||||
WriteTimeout: o.writeTimeout,
|
||||
TLSConfig: o.tlsConfig,
|
||||
}
|
||||
|
||||
// replace single options if provided
|
||||
if o.singleOptions != nil {
|
||||
opt = o.singleOptions
|
||||
}
|
||||
|
||||
rdb := redis.NewClient(opt)
|
||||
|
||||
if o.tracerProvider != nil {
|
||||
err := redisotel.InstrumentTracing(rdb, redisotel.WithTracerProvider(o.tracerProvider))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), 15*time.Second) //nolint
|
||||
err := rdb.Ping(ctx).Err()
|
||||
|
||||
return rdb, err
|
||||
}
|
||||
|
||||
// InitSentinel connecting to redis for sentinel, all redis username and password are the same
|
||||
func InitSentinel(masterName string, addrs []string, username string, password string, opts ...Option) (*redis.Client, error) {
|
||||
o := defaultOptions()
|
||||
o.apply(opts...)
|
||||
|
||||
opt := &redis.FailoverOptions{
|
||||
MasterName: masterName,
|
||||
SentinelAddrs: addrs,
|
||||
Username: username,
|
||||
Password: password,
|
||||
DialTimeout: o.dialTimeout,
|
||||
ReadTimeout: o.readTimeout,
|
||||
WriteTimeout: o.writeTimeout,
|
||||
TLSConfig: o.tlsConfig,
|
||||
}
|
||||
|
||||
// replace sentinel options if provided
|
||||
if o.sentinelOptions != nil {
|
||||
opt = o.sentinelOptions
|
||||
}
|
||||
|
||||
rdb := redis.NewFailoverClient(opt)
|
||||
|
||||
if o.tracerProvider != nil {
|
||||
err := redisotel.InstrumentTracing(rdb, redisotel.WithTracerProvider(o.tracerProvider))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), 15*time.Second) //nolint
|
||||
err := rdb.Ping(ctx).Err()
|
||||
|
||||
return rdb, err
|
||||
}
|
||||
|
||||
// InitCluster connecting to redis for cluster, all redis username and password are the same
|
||||
func InitCluster(addrs []string, username string, password string, opts ...Option) (*redis.ClusterClient, error) {
|
||||
o := defaultOptions()
|
||||
o.apply(opts...)
|
||||
|
||||
opt := &redis.ClusterOptions{
|
||||
Addrs: addrs,
|
||||
Username: username,
|
||||
Password: password,
|
||||
DialTimeout: o.dialTimeout,
|
||||
ReadTimeout: o.readTimeout,
|
||||
WriteTimeout: o.writeTimeout,
|
||||
TLSConfig: o.tlsConfig,
|
||||
}
|
||||
|
||||
// replace cluster options if provided
|
||||
if o.clusterOptions != nil {
|
||||
opt = o.clusterOptions
|
||||
}
|
||||
|
||||
clusterRdb := redis.NewClusterClient(opt)
|
||||
|
||||
if o.tracerProvider != nil {
|
||||
err := redisotel.InstrumentTracing(clusterRdb, redisotel.WithTracerProvider(o.tracerProvider))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), 15*time.Second) //nolint
|
||||
err := clusterRdb.ForEachMaster(ctx, func(ctx context.Context, client *redis.Client) error {
|
||||
return client.Ping(ctx).Err()
|
||||
})
|
||||
|
||||
return clusterRdb, err
|
||||
}
|
||||
|
||||
func getRedisOpt(dsn string, opts *options) (*redis.Options, error) {
|
||||
|
@ -71,70 +192,3 @@ func getRedisOpt(dsn string, opts *options) (*redis.Options, error) {
|
|||
|
||||
return redisOpts, nil
|
||||
}
|
||||
|
||||
// Init2 connecting to redis
|
||||
func Init2(addr string, password string, db int, opts ...Option) *redis.Client {
|
||||
o := defaultOptions()
|
||||
o.apply(opts...)
|
||||
|
||||
rdb := redis.NewClient(&redis.Options{
|
||||
Addr: addr,
|
||||
Password: password,
|
||||
DB: db,
|
||||
DialTimeout: o.dialTimeout,
|
||||
ReadTimeout: o.readTimeout,
|
||||
WriteTimeout: o.writeTimeout,
|
||||
TLSConfig: o.tlsConfig,
|
||||
})
|
||||
|
||||
if o.enableTrace {
|
||||
rdb.AddHook(redisotel.TracingHook{})
|
||||
}
|
||||
|
||||
return rdb
|
||||
}
|
||||
|
||||
// InitSentinel connecting to redis for sentinel, all redis username and password are the same
|
||||
func InitSentinel(masterName string, addrs []string, username string, password string, opts ...Option) *redis.Client {
|
||||
o := defaultOptions()
|
||||
o.apply(opts...)
|
||||
|
||||
rdb := redis.NewFailoverClient(&redis.FailoverOptions{
|
||||
MasterName: masterName,
|
||||
SentinelAddrs: addrs,
|
||||
Username: username,
|
||||
Password: password,
|
||||
DialTimeout: o.dialTimeout,
|
||||
ReadTimeout: o.readTimeout,
|
||||
WriteTimeout: o.writeTimeout,
|
||||
TLSConfig: o.tlsConfig,
|
||||
})
|
||||
|
||||
if o.enableTrace {
|
||||
rdb.AddHook(redisotel.TracingHook{})
|
||||
}
|
||||
|
||||
return rdb
|
||||
}
|
||||
|
||||
// InitCluster connecting to redis for cluster, all redis username and password are the same
|
||||
func InitCluster(addrs []string, username string, password string, opts ...Option) *redis.ClusterClient {
|
||||
o := defaultOptions()
|
||||
o.apply(opts...)
|
||||
|
||||
clusterRdb := redis.NewClusterClient(&redis.ClusterOptions{
|
||||
Addrs: addrs,
|
||||
Username: username,
|
||||
Password: password,
|
||||
DialTimeout: o.dialTimeout,
|
||||
ReadTimeout: o.readTimeout,
|
||||
WriteTimeout: o.writeTimeout,
|
||||
TLSConfig: o.tlsConfig,
|
||||
})
|
||||
|
||||
if o.enableTrace {
|
||||
clusterRdb.AddHook(redisotel.TracingHook{})
|
||||
}
|
||||
|
||||
return clusterRdb
|
||||
}
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
package goredis
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/alicebob/miniredis/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestInit(t *testing.T) {
|
||||
redisServer, _ := miniredis.Run()
|
||||
defer redisServer.Close()
|
||||
addr := redisServer.Addr()
|
||||
|
||||
type args struct {
|
||||
redisURL string
|
||||
}
|
||||
|
@ -19,78 +24,96 @@ func TestInit(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: " no password, no db",
|
||||
args: args{"127.0.0.1:6379"},
|
||||
args: args{addr},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "has password, no db",
|
||||
args: args{"root:123456@127.0.0.1:6379"},
|
||||
args: args{"root:123456@" + addr},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "no password, has db",
|
||||
args: args{"127.0.0.1:6379/5"},
|
||||
args: args{addr + "/5"},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "has password, has db",
|
||||
args: args{"root:123456@127.0.0.1:6379/5"},
|
||||
args: args{fmt.Sprintf("root:123456@%s/5", addr)},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "has redis prefix",
|
||||
args: args{"redis://root:123456@127.0.0.1:6379/7"},
|
||||
args: args{fmt.Sprintf("redis://root:123456@%s/5", addr)},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
_, err := Init(tt.args.redisURL,
|
||||
WithEnableTrace(),
|
||||
rdb, err := Init(tt.args.redisURL,
|
||||
WithDialTimeout(time.Second),
|
||||
WithReadTimeout(time.Second),
|
||||
WithWriteTimeout(time.Second),
|
||||
WithTLSConfig(&tls.Config{}),
|
||||
WithEnableTrace(),
|
||||
WithTracing(nil), // nil means no set field
|
||||
WithTLSConfig(nil), // nil means no set field
|
||||
)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("Init() error = %v, wantErr %v", err, tt.wantErr)
|
||||
t.Logf("error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
assert.NotNil(t, rdb)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestInit2(t *testing.T) {
|
||||
rdb := Init2("127.0.0.1:6379", "123456", 0,
|
||||
WithEnableTrace(),
|
||||
func TestInitSingle(t *testing.T) {
|
||||
redisServer, _ := miniredis.Run()
|
||||
defer redisServer.Close()
|
||||
addr := redisServer.Addr()
|
||||
|
||||
rdb, err := InitSingle(addr, "", 0,
|
||||
WithDialTimeout(time.Second),
|
||||
WithReadTimeout(time.Second),
|
||||
WithWriteTimeout(time.Second),
|
||||
WithTLSConfig(&tls.Config{}),
|
||||
WithTracing(nil), // nil means no set field
|
||||
WithTLSConfig(nil), // nil means no set field
|
||||
WithSingleOptions(nil), // nil means no set field
|
||||
)
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, rdb)
|
||||
}
|
||||
|
||||
func TestInitSentinel(t *testing.T) {
|
||||
addrs := []string{"127.0.0.1:6380", "127.0.0.1:6381", "127.0.0.1:6382"}
|
||||
rdb := InitSentinel("master", addrs, "default", "123456",
|
||||
WithEnableTrace(),
|
||||
redisServer, _ := miniredis.Run()
|
||||
defer redisServer.Close()
|
||||
addr := redisServer.Addr()
|
||||
|
||||
rdb, err := InitSentinel("mymaster", []string{addr}, "", "",
|
||||
WithDialTimeout(time.Second),
|
||||
WithReadTimeout(time.Second),
|
||||
WithWriteTimeout(time.Second),
|
||||
WithTLSConfig(&tls.Config{}),
|
||||
WithTracing(nil), // nil means no set field
|
||||
WithTLSConfig(nil), // nil means no set field
|
||||
WithSentinelOptions(nil), // nil means no set field
|
||||
)
|
||||
t.Log(err)
|
||||
assert.NotNil(t, rdb)
|
||||
}
|
||||
|
||||
func TestInitCluster(t *testing.T) {
|
||||
addrs := []string{"127.0.0.1:6380", "127.0.0.1:6381", "127.0.0.1:6382"}
|
||||
clusterRdb := InitCluster(addrs, "default", "123456",
|
||||
WithEnableTrace(),
|
||||
WithDialTimeout(time.Second),
|
||||
redisServer, _ := miniredis.Run()
|
||||
defer redisServer.Close()
|
||||
addr := redisServer.Addr()
|
||||
|
||||
clusterRdb, err := InitCluster([]string{addr}, "", "",
|
||||
WithDialTimeout(time.Second*15),
|
||||
WithReadTimeout(time.Second),
|
||||
WithWriteTimeout(time.Second),
|
||||
WithTLSConfig(&tls.Config{}),
|
||||
WithTracing(nil), // nil means no set field
|
||||
WithTLSConfig(nil), // nil means no set field
|
||||
WithClusterOptions(nil), // nil means no set field
|
||||
)
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, clusterRdb)
|
||||
}
|
||||
|
|
|
@ -3,18 +3,32 @@ package goredis
|
|||
import (
|
||||
"crypto/tls"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"go.opentelemetry.io/otel/sdk/trace"
|
||||
)
|
||||
|
||||
// Option set the redis options.
|
||||
type Option func(*options)
|
||||
|
||||
type options struct {
|
||||
enableTrace bool
|
||||
dialTimeout time.Duration
|
||||
readTimeout time.Duration
|
||||
writeTimeout time.Duration
|
||||
tlsConfig *tls.Config
|
||||
|
||||
tlsConfig *tls.Config
|
||||
// Note: this field is only used for Init and InitSingle, and the other parameters will be ignored.
|
||||
singleOptions *redis.Options
|
||||
|
||||
// Note: this field is only used for InitSentinel, and the other parameters will be ignored.
|
||||
sentinelOptions *redis.FailoverOptions
|
||||
|
||||
// Note: this field is only used for InitCluster, and the other parameters will be ignored.
|
||||
clusterOptions *redis.ClusterOptions
|
||||
|
||||
// deprecated: use tp instead
|
||||
enableTrace bool
|
||||
tracerProvider *trace.TracerProvider
|
||||
}
|
||||
|
||||
func (o *options) apply(opts ...Option) {
|
||||
|
@ -30,13 +44,21 @@ func defaultOptions() *options {
|
|||
}
|
||||
}
|
||||
|
||||
// WithEnableTrace use trace
|
||||
// WithEnableTrace use trace, redis v8
|
||||
// Deprecated: use WithEnableTracer instead
|
||||
func WithEnableTrace() Option {
|
||||
return func(o *options) {
|
||||
o.enableTrace = true
|
||||
}
|
||||
}
|
||||
|
||||
// WithTracing set redis tracer provider, redis v9
|
||||
func WithTracing(tp *trace.TracerProvider) Option {
|
||||
return func(o *options) {
|
||||
o.tracerProvider = tp
|
||||
}
|
||||
}
|
||||
|
||||
// WithDialTimeout set dail timeout
|
||||
func WithDialTimeout(t time.Duration) Option {
|
||||
return func(o *options) {
|
||||
|
@ -64,3 +86,24 @@ func WithTLSConfig(c *tls.Config) Option {
|
|||
o.tlsConfig = c
|
||||
}
|
||||
}
|
||||
|
||||
// WithSingleOptions set single redis options
|
||||
func WithSingleOptions(opt *redis.Options) Option {
|
||||
return func(o *options) {
|
||||
o.singleOptions = opt
|
||||
}
|
||||
}
|
||||
|
||||
// WithSentinelOptions set redis sentinel options
|
||||
func WithSentinelOptions(opt *redis.FailoverOptions) Option {
|
||||
return func(o *options) {
|
||||
o.sentinelOptions = opt
|
||||
}
|
||||
}
|
||||
|
||||
// WithClusterOptions set redis cluster options
|
||||
func WithClusterOptions(opt *redis.ClusterOptions) Option {
|
||||
return func(o *options) {
|
||||
o.clusterOptions = opt
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
|
||||
"github.com/alicebob/miniredis/v2"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/zhufuyi/sponge/pkg/utils"
|
||||
)
|
||||
|
@ -58,3 +58,55 @@ func (c *Cache) GetIDs() []uint64 {
|
|||
func (c *Cache) GetTestData() map[string]interface{} {
|
||||
return c.TestDataMap
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------
|
||||
|
||||
// RCCache redis cluster cache
|
||||
type RCCache struct {
|
||||
Ctx context.Context
|
||||
TestDataSlice []interface{}
|
||||
TestDataMap map[string]interface{}
|
||||
RedisClient *redis.ClusterClient
|
||||
redisServer *miniredis.Miniredis
|
||||
ICache interface{}
|
||||
}
|
||||
|
||||
// NewRCCache instantiated redis cluster cache
|
||||
func NewRCCache(testDataMap map[string]interface{}) *RCCache {
|
||||
var tds []interface{}
|
||||
for _, data := range testDataMap {
|
||||
tds = append(tds, data)
|
||||
}
|
||||
|
||||
redisServer, err := miniredis.Run()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return &RCCache{
|
||||
Ctx: context.Background(),
|
||||
TestDataSlice: tds,
|
||||
TestDataMap: testDataMap,
|
||||
RedisClient: redis.NewClusterClient(&redis.ClusterOptions{Addrs: []string{redisServer.Addr()}}),
|
||||
redisServer: redisServer,
|
||||
}
|
||||
}
|
||||
|
||||
// Close redis server
|
||||
func (c *RCCache) Close() {
|
||||
c.redisServer.Close()
|
||||
}
|
||||
|
||||
// GetIDs get test data ids
|
||||
func (c *RCCache) GetIDs() []uint64 {
|
||||
var ids []uint64
|
||||
for idStr := range c.TestDataMap {
|
||||
ids = append(ids, utils.StrToUint64(idStr))
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// GetTestData get test data
|
||||
func (c *RCCache) GetTestData() map[string]interface{} {
|
||||
return c.TestDataMap
|
||||
}
|
||||
|
|
|
@ -4,40 +4,55 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestNewRedisCache(t *testing.T) {
|
||||
var testData = map[string]interface{}{
|
||||
func getTestData() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"1": "foo",
|
||||
"2": "bar",
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewRedisCache(t *testing.T) {
|
||||
testData := getTestData()
|
||||
c := NewCache(testData)
|
||||
c.ICache = struct{}{}
|
||||
|
||||
defer c.Close()
|
||||
c.Close()
|
||||
}
|
||||
|
||||
func TestRedisCache_GetIDs(t *testing.T) {
|
||||
var testData = map[string]interface{}{
|
||||
"1": "foo",
|
||||
"2": "bar",
|
||||
}
|
||||
|
||||
testData := getTestData()
|
||||
c := NewCache(testData)
|
||||
c.ICache = struct{}{}
|
||||
defer c.Close()
|
||||
|
||||
c.Close()
|
||||
t.Log(c.GetIDs())
|
||||
}
|
||||
|
||||
func TestRedisCache_GetTestData(t *testing.T) {
|
||||
var testData = map[string]interface{}{
|
||||
"1": "foo",
|
||||
"2": "bar",
|
||||
}
|
||||
|
||||
testData := getTestData()
|
||||
c := NewCache(testData)
|
||||
c.ICache = struct{}{}
|
||||
defer c.Close()
|
||||
|
||||
c.Close()
|
||||
t.Log(c.GetTestData())
|
||||
}
|
||||
|
||||
func TestNewRedisClusterCache(t *testing.T) {
|
||||
testData := getTestData()
|
||||
c := NewCache(testData)
|
||||
c.ICache = struct{}{}
|
||||
c.Close()
|
||||
}
|
||||
|
||||
func TestRedisClusterCache_GetIDs(t *testing.T) {
|
||||
testData := getTestData()
|
||||
rc := NewRCCache(testData)
|
||||
rc.ICache = struct{}{}
|
||||
rc.Close()
|
||||
t.Log(rc.GetIDs())
|
||||
}
|
||||
|
||||
func TestRedisClusterCache_GetTestData(t *testing.T) {
|
||||
testData := getTestData()
|
||||
rc := NewRCCache(testData)
|
||||
rc.ICache = struct{}{}
|
||||
rc.Close()
|
||||
t.Log(rc.GetTestData())
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ func (b *Breaker) Allow() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MarkSuccess mark requeest is success.
|
||||
// MarkSuccess mark request is success.
|
||||
func (b *Breaker) MarkSuccess() {
|
||||
b.stat.Add(1)
|
||||
}
|
||||
|
|
|
@ -63,3 +63,11 @@ func InitWithConfig(appName string, appEnv string, appVersion string,
|
|||
|
||||
SetTraceName(appName)
|
||||
}
|
||||
|
||||
// GetProvider get tracer provider
|
||||
func GetProvider() *trace.TracerProvider {
|
||||
if tp == nil {
|
||||
panic("tracer provider is nil, initialize it first with InitWithConfig(...)")
|
||||
}
|
||||
return tp
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ func TestClose(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
resource := NewResource()
|
||||
Init(exporter, resource)
|
||||
GetProvider()
|
||||
_ = Close(context.Background())
|
||||
|
||||
tp = nil
|
||||
|
|
Loading…
Reference in New Issue