Skip to content

Commit

Permalink
Merge pull request #13 from GuGoOrg/dev
Browse files Browse the repository at this point in the history
fix: grpc error
  • Loading branch information
liaosunny123 authored Aug 4, 2023
2 parents 7aae63b + ced5462 commit fa3cc5f
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 62 deletions.
4 changes: 4 additions & 0 deletions src/constant/config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ FS_BASEURL=http://localhost/
# Configure redis host
# `REDIS_PASSWORD` has a default value ''
# `REDIS_DB` has a default value '0'
# TIPS: There is a Auto choose mode for Redis
# TIPS: You can opt to use `Single Redis Node` with providing a single ip
# TIPS: You can opt to use `Redis Cluster` with providing multi redis using ';' to split
# TIPS: When you trying to use Redis Cluster, you should ensure they have the same password or have no password
REDIS_ADDR=127.0.0.1:6379
REDIS_PASSWORD=
REDIS_DB=
Expand Down
2 changes: 1 addition & 1 deletion src/idl/user.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ option go_package = "GuGoTik/src/rpc/user";

message UserRequest {
int64 user_id = 1; // 用户id
string token = 2; // 用户鉴权token
uint32 actor_id = 2; // 发送请求的用户的id
}

message UserResponse {
Expand Down
115 changes: 58 additions & 57 deletions src/rpc/user/user.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions src/storage/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ import (
"GuGoTik/src/constant/config"
"github.com/redis/go-redis/extra/redisotel/v9"
"github.com/redis/go-redis/v9"
"strings"
)

var Client *redis.Client
var Client redis.UniversalClient

func init() {
Client = redis.NewClient(&redis.Options{
Addr: config.EnvCfg.RedisAddr,
addrs := strings.Split(config.EnvCfg.RedisAddr, ";")
Client = redis.NewUniversalClient(&redis.UniversalOptions{
Addrs: addrs,
Password: config.EnvCfg.RedisPassword,
DB: config.EnvCfg.RedisDB,
})

if err := redisotel.InstrumentTracing(Client); err != nil {
panic(err)
}

if err := redisotel.InstrumentMetrics(Client); err != nil {
panic(err)
}
}
2 changes: 1 addition & 1 deletion src/web/auth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func RegisterHandle(c *gin.Context) {
logger := logging.LogService("GateWay.Register").WithContext(c.Request.Context())

if err := c.ShouldBindQuery(&req); err != nil {
c.JSON(http.StatusOK, models.LoginRes{
c.JSON(http.StatusOK, models.RegisterRes{
StatusCode: strings.GateWayParamsErrorCode,
StatusMsg: strings.GateWayParamsError,
UserId: 0,
Expand Down

0 comments on commit fa3cc5f

Please sign in to comment.