mirror of
https://github.com/smallnest/rpcx.git
synced 2025-10-06 08:37:08 +08:00
add reflection so that you can use it to get definition of services
This commit is contained in:
28
reflection/server_reflection_test.go
Normal file
28
reflection/server_reflection_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package reflection
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/kr/pretty"
|
||||
|
||||
testutils "github.com/smallnest/rpcx/_testutils"
|
||||
)
|
||||
|
||||
type PBArith int
|
||||
|
||||
func (t *PBArith) Mul(ctx context.Context, args *testutils.ProtoArgs, reply *testutils.ProtoReply) error {
|
||||
reply.C = args.A * args.B
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestReflection_Register(t *testing.T) {
|
||||
r := New()
|
||||
arith := PBArith(0)
|
||||
err := r.Register("Arith", &arith, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
pretty.Println(r.Services["PBArith"].String())
|
||||
}
|
Reference in New Issue
Block a user