重构代码结构与认证体系,集成异步任务消费者
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package globals
|
||||
|
||||
import (
|
||||
"github.com/go-redsync/redsync/v4/redis/goredis/v9"
|
||||
"log/slog"
|
||||
"net"
|
||||
"platform/pkg/env"
|
||||
"platform/web/core"
|
||||
|
||||
"github.com/go-redsync/redsync/v4/redis/goredis/v9"
|
||||
|
||||
"github.com/go-redsync/redsync/v4"
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
@@ -18,11 +19,10 @@ type ExtendRedSync struct {
|
||||
*redsync.Redsync
|
||||
}
|
||||
|
||||
func initRedis() {
|
||||
func initRedis() error {
|
||||
client := redis.NewClient(&redis.Options{
|
||||
Addr: net.JoinHostPort(env.RedisHost, env.RedisPort),
|
||||
DB: env.RedisDb,
|
||||
Password: env.RedisPass,
|
||||
Password: env.RedisPassword,
|
||||
})
|
||||
|
||||
pool := goredis.NewPool(client)
|
||||
@@ -30,9 +30,11 @@ func initRedis() {
|
||||
|
||||
Redis = client
|
||||
Redsync = &ExtendRedSync{sync}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ExitRedis() error {
|
||||
func stopRedis() error {
|
||||
if Redis != nil {
|
||||
return Redis.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user