2017-05-26 02:36:46 +00:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
2017-05-29 11:39:56 +00:00
|
|
|
pb "git.loafle.net/overflow/overflow_api_db/build/golang"
|
2017-05-26 02:36:46 +00:00
|
|
|
"google.golang.org/grpc"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
2017-05-30 03:13:26 +00:00
|
|
|
func InvokeDB(targetDb, methodName string, param map[string]string) (string) {
|
2017-05-26 02:36:46 +00:00
|
|
|
|
|
|
|
in := &pb.DBInput{}
|
|
|
|
in.TargetDao = targetDb
|
|
|
|
in.Method = methodName
|
|
|
|
in.Param = param
|
|
|
|
|
|
|
|
conn, err := grpc.Dial("192.168.1.105: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
|
|
|
|
}
|