✨ updated
This commit is contained in:
@@ -1,24 +1,31 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/stores/redis"
|
||||
"github.com/lionsoul2014/ip2region/binding/golang/xdb"
|
||||
"github.com/rbcervilla/redisstore/v9"
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
"go.mongodb.org/mongo-driver/v2/mongo"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/core/api/internal/config"
|
||||
"schisandra-album-cloud-microservices/app/core/api/internal/middleware"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/ip2region"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mongodb"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/mysql/ent"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/redis_session"
|
||||
"schisandra-album-cloud-microservices/app/core/api/repository/redisx"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SecurityHeadersMiddleware rest.Middleware
|
||||
MySQLClient *ent.Client
|
||||
RedisClient *redis.Redis
|
||||
RedisClient *redis.Client
|
||||
MongoClient *mongo.Database
|
||||
Session *redisstore.RedisStore
|
||||
Ip2Region *xdb.Searcher
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
@@ -26,12 +33,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
Config: c,
|
||||
SecurityHeadersMiddleware: middleware.NewSecurityHeadersMiddleware().Handle,
|
||||
MySQLClient: mysql.NewMySQL(c.Mysql.DataSource),
|
||||
RedisClient: redis.MustNewRedis(redis.RedisConf{
|
||||
Host: c.Redis.Host,
|
||||
Pass: c.Redis.Pass,
|
||||
Type: c.Redis.Type,
|
||||
Tls: c.Redis.Tls,
|
||||
}),
|
||||
MongoClient: mongodb.NewMongoDB(c.Mongo.Uri, c.Mongo.Username, c.Mongo.Password, c.Mongo.AuthSource, c.Mongo.Database),
|
||||
RedisClient: redisx.NewRedis(c.Redis.Host, c.Redis.Pass, c.Redis.DB),
|
||||
MongoClient: mongodb.NewMongoDB(c.Mongo.Uri, c.Mongo.Username, c.Mongo.Password, c.Mongo.AuthSource, c.Mongo.Database),
|
||||
Session: redis_session.NewRedisSession(c.Redis.Host, c.Redis.Pass),
|
||||
Ip2Region: ip2region.NewIP2Region(),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user