callctx 수정

This commit is contained in:
2023-07-10 10:53:49 +09:00
parent e912c88993
commit 98efbc2875
2 changed files with 42 additions and 5 deletions

View File

@ -1,7 +1,42 @@
package rpc
import "testing"
import (
"context"
"testing"
"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 {
return tid[0] >= 10
}
func (tr *testReceiver) TestFunc(a string, b string) {
logger.Println("TestFunc :", a, b)
target := primitive.NewObjectID()
target[0] = 0
if CallOrGo(tr, target, a, b) != ErrCanExecuteHere {
return
}
logger.Println(a, b)
}
func TestRpc(t *testing.T) {
var tr testReceiver
RegistReceiver(&tr)
myctx, cancel := context.WithCancel(context.Background())
redisClient, _ := gocommon.NewRedisClient("redis://192.168.8.94:6379", 0)
Start(myctx, redisClient)
tr.TestFunc("aaa", "bb")
<-myctx.Done()
cancel()
}