Browse Source

add redis config

davy66666 1 tháng trước cách đây
mục cha
commit
e98dbc78c0
3 tập tin đã thay đổi với 19 bổ sung2 xóa
  1. 1 0
      etc/rtc.yaml
  2. 12 1
      internal/config/config.go
  3. 6 1
      internal/svc/servicecontext.go

+ 1 - 0
etc/rtc.yaml

@@ -10,6 +10,7 @@ Redis:
   Type: node
   Pass: "KRXbzyT1mLseE8GJ8UgCir0txCf"       # 如果 Redis 有密码,可以在这里设置
   Tls: false         # 最小空闲连接数
+  Key: rtc
 
 openimRpcName:
   user: user

+ 12 - 1
internal/config/config.go

@@ -1,7 +1,18 @@
 package config
 
-import "github.com/zeromicro/go-zero/zrpc"
+import (
+	"github.com/zeromicro/go-zero/core/stores/redis"
+	"github.com/zeromicro/go-zero/zrpc"
+)
 
 type Config struct {
 	zrpc.RpcServerConf
+	RedisConf redis.RedisConf
+	Rtc       Rtc
+}
+
+type Rtc struct {
+	Url       string
+	apiKey    string
+	apiSecret string
 }

+ 6 - 1
internal/svc/servicecontext.go

@@ -1,13 +1,18 @@
 package svc
 
-import "self-im-rtc/internal/config"
+import (
+	"github.com/zeromicro/go-zero/core/stores/redis"
+	"self-im-rtc/internal/config"
+)
 
 type ServiceContext struct {
 	Config config.Config
+	Redis  *redis.Redis
 }
 
 func NewServiceContext(c config.Config) *ServiceContext {
 	return &ServiceContext{
 		Config: c,
+		Redis:  redis.MustNewRedis(c.RedisConf),
 	}
 }