Squashed commit of the following:

commit 8e1b232d57
Author: mountain <mountain@action2quare.com>
Date:   Wed Jul 19 09:37:02 2023 +0900

    InMemory 그룹을 redis로 변경

commit 01da5bb3a4
Author: mountain <mountain@action2quare.com>
Date:   Tue Jul 18 01:31:39 2023 +0900

    body를 marshaling하고 클라이언트에서 flatten함

commit ba61a11659
Author: mountain <mountain@action2quare.com>
Date:   Mon Jul 17 17:47:07 2023 +0900

    gob 등록

commit 67cca13326
Author: mountain <mountain@action2quare.com>
Date:   Sun Jul 16 18:41:24 2023 +0900

    모듈 업데이트

commit 272c696c59
Author: mountain <mountain@action2quare.com>
Date:   Sun Jul 16 17:29:21 2023 +0900

    json value 다시 되돌림

commit aa568ec3fa
Author: mountain <mountain@action2quare.com>
Date:   Sun Jul 16 17:26:19 2023 +0900

    SetOption 타입 변경

commit b9c4d8b21b
Author: mountain <mountain@action2quare.com>
Date:   Sun Jul 16 17:15:08 2023 +0900

    objvalue marshalling 수정

commit 99834c1461
Author: mountain <mountain@action2quare.com>
Date:   Sun Jul 16 17:01:06 2023 +0900

    objlen 수정

commit 592112219e
Author: mountain <mountain@action2quare.com>
Date:   Sun Jul 16 16:38:05 2023 +0900

    gocommon 업데이트

commit 62485b6d54
Author: mountain <mountain@action2quare.com>
Date:   Sun Jul 16 15:36:20 2023 +0900

    redis json 마이그레이션 완료

commit d36dd13bb7
Author: mountain <mountain@action2quare.com>
Date:   Sun Jul 16 02:51:41 2023 +0900

    redis stack 사용
This commit is contained in:
2023-07-19 09:37:40 +09:00
parent 454aae5294
commit 8dded8b907
11 changed files with 565 additions and 1419 deletions

77
core/tavern_test.go Normal file
View File

@ -0,0 +1,77 @@
// warroom project main.go
package core
import (
"context"
"fmt"
"testing"
"time"
"github.com/go-redis/redis/v8"
"go.mongodb.org/mongo-driver/bson/primitive"
"repositories.action2quare.com/ayo/gocommon"
"repositories.action2quare.com/ayo/gocommon/logger"
)
func TestPubSub(t *testing.T) {
opt0, _ := redis.ParseURL("redis://192.168.8.94:6380/0")
opt1, _ := redis.ParseURL("redis://192.168.8.94:6380/1")
rc0 := redis.NewClient(opt0)
rc1 := redis.NewClient(opt1)
go func() {
time.Sleep(time.Second)
rc1.Publish(context.Background(), "__testchan", "real???")
fmt.Println("published")
}()
pubsub := rc0.Subscribe(context.Background(), "__testchan")
msg, err := pubsub.ReceiveMessage(context.Background())
fmt.Println(msg.Payload, err)
}
func TestReJSON(t *testing.T) {
rc := redis.NewClient(&redis.Options{Addr: "192.168.8.94:6380"})
rh := gocommon.NewRedisonHandler(context.Background(), rc)
testDoc := map[string]any{
"members": map[string]any{
"mid2": map[string]any{
"key": "val",
"exp": 20202020,
},
"mid1": map[string]any{
"key": "val",
"exp": 10101010,
},
},
}
gd := groupDoc{
id: primitive.NewObjectID(),
}
midin := primitive.NewObjectID()
tid := gd.tid(midin)
midout := gd.mid(tid)
logger.Println(midin, tid, midout)
logger.Println(rh.JSONSet("jsontest", "$", testDoc))
logger.Println(rh.JSONGet("jsontest", "$"))
logger.Println(rh.JSONResp("jsontest", "$.members"))
logger.Println(rh.JSONGetString("jsontest", "$.members..key"))
logger.Println(rh.JSONGetInt64("jsontest", "$.members..exp"))
logger.Println(rh.JSONObjKeys("jsontest", "$.members"))
err := rh.JSONMSet("jsontest", map[string]any{
"$.members.mid1.key": "newval",
"$.members.mid2.key": "newval",
})
logger.Println(err)
logger.Println(rh.JSONGet("jsontest", "$"))
logger.Println(rh.JSONMDel("jsontest", []string{"$.members.mid1", "$.members.mid2"}))
logger.Println(rh.JSONGet("jsontest", "$"))
logger.Println(rh.JSONObjLen("jsontest", "$.members"))
}