Skip to content
Snippets Groups Projects
Commit 2a18c933 authored by Pawan Rawal's avatar Pawan Rawal
Browse files

Verifying rpc works

Also query is now input as a flag in the client
parent fb8f45da
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,6 @@ import (
"fmt"
"golang.org/x/net/context"
"google.golang.org/grpc"
"github.com/dgraph-io/dgraph/query/pb"
......@@ -30,18 +29,10 @@ import (
var glog = x.Log("client")
var port = flag.String("port", "9090", "Port to communicate with server")
var query = flag.String("query", "", "Query sent to the server")
func main() {
// TODO(pawan) - Remove hardcoded query. Give helper methods to user for building query.
var q0 = `{
me(_xid_: m.0f4vbz) {
type.object.name.en
film.actor.film {
type.object.name.en
}
}
}`
flag.Parse()
// TODO(pawan): Pick address for server from config
conn, err := grpc.Dial("127.0.0.1:"+*port, grpc.WithInsecure())
if err != nil {
......@@ -51,7 +42,7 @@ func main() {
c := pb.NewDGraphClient(conn)
r, err := c.GetGraphResponse(context.Background(), &pb.GraphRequest{Query: q0})
r, err := c.GetResponse(context.Background(), &pb.GraphRequest{Query: *query})
if err != nil {
x.Err(glog, err).Fatal("Error in getting response from server")
}
......
......@@ -50,7 +50,7 @@ var postingDir = flag.String("postings", "", "Directory to store posting lists")
var uidDir = flag.String("uids", "", "XID UID posting lists directory")
var mutationDir = flag.String("mutations", "", "Directory to store mutations")
var port = flag.String("port", "8080", "Port to run server on.")
var clientPort = flag.String("port", "9090", "Port used to communicate with client on tcp")
var clientPort = flag.String("clientPort", "9090", "Port used to communicate with client on tcp")
var numcpu = flag.Int("numCpu", runtime.NumCPU(),
"Number of cores to be used by the process")
var instanceIdx = flag.Uint64("instanceIdx", 0,
......@@ -256,7 +256,10 @@ func runServerForClient(address string) error {
s := grpc.NewServer()
pb.RegisterDGraphServer(s, &server{})
s.Serve(ln)
if err = s.Serve(ln); err != nil {
glog.Fatalf("While serving gRpc requests", err)
}
return nil
}
func main() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment