d45b1a5dcc
member unmashal test code
33 lines
638 B
Go
33 lines
638 B
Go
package proxy
|
|
|
|
import (
|
|
"log"
|
|
pb "git.loafle.net/overflow/overflow_api_db/build/golang"
|
|
"google.golang.org/grpc"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
|
|
func InvokeDB(targetDb, methodName string, param map[string]string) (string) {
|
|
|
|
in := &pb.DBInput{}
|
|
in.TargetDao = targetDb
|
|
in.Method = methodName
|
|
in.Param = param
|
|
|
|
conn, err := grpc.Dial("192.168.1.209:50006", grpc.WithInsecure())
|
|
|
|
if err != nil {
|
|
log.Fatal("Rpc Error: ", err)
|
|
}
|
|
defer conn.Close()
|
|
|
|
client := pb.NewDBClient(conn)
|
|
out, err := client.Exec(context.Background(), in)
|
|
if err != nil {
|
|
log.Fatal("Rpc Client Error: ", err)
|
|
}
|
|
log.Print(out)
|
|
|
|
return out.Result
|
|
} |