Files
gocommon/rpc/rpc_test.go

49 lines
967 B
Go
Raw Normal View History

2023-07-10 10:29:16 +09:00
package rpc
2023-07-10 10:53:49 +09:00
import (
"context"
2023-07-10 12:28:32 +09:00
"math/rand"
2023-07-10 10:53:49 +09:00
"testing"
"time"
2023-07-10 10:53:49 +09:00
"go.mongodb.org/mongo-driver/bson/primitive"
"repositories.action2quare.com/ayo/gocommon"
"repositories.action2quare.com/ayo/gocommon/logger"
)
type testReceiver struct {
}
func (tr *testReceiver) TargetExists(tid primitive.ObjectID) bool {
logger.Println(tid.Hex())
2023-07-10 10:53:49 +09:00
return tid[0] >= 10
}
func (tr *testReceiver) TestFunc(a string, b string, c int) {
2023-07-10 10:53:49 +09:00
target := primitive.NewObjectID()
2023-07-10 12:28:32 +09:00
target[0] = byte(rand.Intn(2) * 20)
2023-07-10 14:30:24 +09:00
if Make(tr).To(target).Call(a, b, c) != ErrCanExecuteHere {
2023-07-10 10:53:49 +09:00
return
}
2023-07-10 12:28:32 +09:00
logger.Println(" ", a, b, target[0])
2023-07-10 10:53:49 +09:00
}
2023-07-10 10:29:16 +09:00
func TestRpc(t *testing.T) {
2023-07-10 10:53:49 +09:00
var tr testReceiver
RegistReceiver(&tr)
myctx, cancel := context.WithCancel(context.Background())
Squashed commit of the following: commit 29b2f258507d9e11e20a9693b86b3ae09e10d88c Author: mountain <mountain@action2quare.com> Date: Wed Jul 19 09:33:37 2023 +0900 타입 이름 변경 commit 256bfd030c294d2d7bea4ca2c3082f2d49ae9aef Author: mountain <mountain@action2quare.com> Date: Wed Jul 19 09:31:01 2023 +0900 redison 추가 commit 72a683fed2c024616b2171be1f6841a11150a3a8 Author: mountain <mountain@action2quare.com> Date: Tue Jul 18 19:51:24 2023 +0900 gob에 []any 추가 commit 89fa9e4ac585026c331d697929697af5defc6b9d Author: mountain <mountain@action2quare.com> Date: Tue Jul 18 17:45:12 2023 +0900 write control 수정 commit d724cc84fa94ab6cdd3d8bddd3ab08c99d0aef3a Author: mountain <mountain@action2quare.com> Date: Tue Jul 18 17:38:04 2023 +0900 redis pubsub 채널 이름에 디비 인덱스 추가 commit 8df248fa54908a8cb547813179e4269e25c7df87 Author: mountain <mountain@action2quare.com> Date: Tue Jul 18 17:20:47 2023 +0900 close를 writecontrol로 변경 commit 40a603522d4082f426a0d3818d852db53e458cd2 Author: mountain <mountain@action2quare.com> Date: Tue Jul 18 12:21:06 2023 +0900 conn에 msg를 쓰는 쓰레드 단일화 commit c21017d2cd8b2bd26bdbf6d4eca49d06b8462ce0 Author: mountain <mountain@action2quare.com> Date: Tue Jul 18 11:08:38 2023 +0900 redis call이 문제가 아니었음 commit 82abcddb497bdb95b0eff2d7a98b72cacf37bc9a Author: mountain <mountain@action2quare.com> Date: Tue Jul 18 11:04:15 2023 +0900 잦은 redis call 회피 commit 289af24a8ffaa55336bfabca151a71f6e1f82290 Author: mountain <mountain@action2quare.com> Date: Tue Jul 18 09:55:18 2023 +0900 room create 메시지 전송 commit 4b35e0e6386b1a27e4dec854d1fc2c755f20aeef Author: mountain <mountain@action2quare.com> Date: Tue Jul 18 09:45:27 2023 +0900 EventReceiver 인터페이스 추가 commit 29843802ff0eb6378af63b2a14de826a594f5a9e Author: mountain <mountain@action2quare.com> Date: Mon Jul 17 17:45:40 2023 +0900 gob 등록 commit 66aea48fb7322728d0f665e37b2dd818f441c26f Author: mountain <mountain@action2quare.com> Date: Sun Jul 16 18:39:11 2023 +0900 채널간 publish marshalling을 gob으로 변경 commit 8f6c87a8aeb86f8fb41ba7a5ff75e3e8ee9ede2c Author: mountain <mountain@action2quare.com> Date: Sun Jul 16 16:37:02 2023 +0900 redis option을 copy로 변경 commit f0f459332d1a62a938a9b9b7ca34e3d3a2f26e8c Author: mountain <mountain@action2quare.com> Date: Sat Jul 15 17:08:33 2023 +0900 wshandler에서 authcache제거하고 config 포맷 변경
2023-07-19 09:35:25 +09:00
redisClient, _ := gocommon.NewRedisClient("redis://192.168.8.94:6379")
go func() {
for {
tr.TestFunc("aaaa", "bbbb", 333)
time.Sleep(time.Second)
}
}()
2023-07-10 10:29:16 +09:00
Start(myctx, redisClient)
2023-07-10 10:53:49 +09:00
<-myctx.Done()
cancel()
2023-07-10 10:29:16 +09:00
}