redis json 마이그레이션 완료

This commit is contained in:
2023-07-16 15:36:20 +09:00
parent d36dd13bb7
commit 62485b6d54
6 changed files with 381 additions and 301 deletions

View File

@ -7,7 +7,6 @@ import (
"time"
"github.com/go-redis/redis/v8"
"github.com/nitishm/go-rejson/v4/rjs"
"repositories.action2quare.com/ayo/gocommon"
"repositories.action2quare.com/ayo/gocommon/logger"
"repositories.action2quare.com/ayo/gocommon/wshandler"
@ -50,7 +49,7 @@ type groupDoc struct {
Members map[string]*memberDoc `json:"members"`
InCharge string `json:"incharge"`
rh *RejsonHandler
rh *RedisonHandler
id groupID
idhex string
}
@ -134,7 +133,7 @@ func (gd *groupDoc) addMember(mid accountID, doc bson.M) (*memberDoc, error) {
Body: doc,
}
if _, err := gd.rh.JSONSet(gd.strid(), "$.members."+gd.tid(mid), memdoc, rjs.SetOptionXX); err != nil {
if _, err := gd.rh.JSONSet(gd.strid(), "$.members."+gd.tid(mid), memdoc, SetOptionXX); err != nil {
return nil, err
}
@ -151,7 +150,7 @@ type groupInMemory struct {
sendUpstreamMessage func(*wshandler.UpstreamMessage)
sendEnterRoomMessage func(groupID, accountID)
sendLeaveRoomMessage func(groupID, accountID)
rh *RejsonHandler
rh *RedisonHandler
}
func (gm *groupInMemory) createGroup(newid groupID, charge accountID, chargeDoc bson.M) (*groupDoc, error) {
@ -172,7 +171,7 @@ func (gm *groupInMemory) createGroup(newid groupID, charge accountID, chargeDoc
id: newid,
}
_, err := gm.rh.JSONSet(gd.strid(), "$", gd, rjs.SetOptionNX)
_, err := gm.rh.JSONSet(gd.strid(), "$", gd, SetOptionNX)
if err != nil {
return nil, err
}
@ -367,7 +366,7 @@ func (gm *groupInMemory) UpdateMemberDocument(gid groupID, mid accountID, doc bs
id: gid,
rh: gm.rh,
}
_, err := gm.rh.JSONSet(gd.strid(), "$.members."+gd.tid(mid)+".body", doc, rjs.SetOptionXX)
_, err := gm.rh.JSONSet(gd.strid(), "$.members."+gd.tid(mid)+".body", doc, SetOptionXX)
if err != nil {
return err
}
@ -392,7 +391,7 @@ func (gm *groupInMemory) UpdateGroupDocument(gid groupID, body []byte) error {
id: gid,
rh: gm.rh,
}
_, err := gm.rh.JSONSet(gd.strid(), "$.members.body", body, rjs.SetOptionXX)
_, err := gm.rh.JSONSet(gd.strid(), "$.members.body", body, SetOptionXX)
return err
}
@ -410,7 +409,7 @@ func (cfg *groupConfig) prepareInMemory(ctx context.Context, typename string, su
// 각 함수에서는 publish
gm := &groupInMemory{
groupConfig: cfg,
rh: NewReJSONHandler(ctx, redisClient),
rh: NewRedisonHandler(ctx, redisClient),
sendUpstreamMessage: func(msg *wshandler.UpstreamMessage) {
wsh.SendUpstreamMessage(region, msg)
},