From 2a18c933e4893c2bdf49ad33b9d8e6c1b083c513 Mon Sep 17 00:00:00 2001
From: Pawan Rawal <pawan0201@gmail.com>
Date: Tue, 19 Apr 2016 15:16:08 +0530
Subject: [PATCH] Verifying rpc works

Also query is now input as a flag in the client
---
 client/go/main.go | 15 +++------------
 server/main.go    |  7 +++++--
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/client/go/main.go b/client/go/main.go
index ca2d662f..53f741a4 100644
--- a/client/go/main.go
+++ b/client/go/main.go
@@ -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")
 	}
diff --git a/server/main.go b/server/main.go
index 8a0df9b9..39f710e6 100644
--- a/server/main.go
+++ b/server/main.go
@@ -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() {
-- 
GitLab