Skip to content

Commit

Permalink
fixing rpc server, example nyt & updating rpc example client
Browse files Browse the repository at this point in the history
  • Loading branch information
jprobinson committed Mar 19, 2016
1 parent fbee99c commit f5b781a
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 69 deletions.
6 changes: 3 additions & 3 deletions examples/nyt/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (c *ClientImpl) GetMostPopular(resourceType string, section string, timePer
}

err = json.Unmarshal(rawRes, &res)
return res.Result, err
return res.Results, err
}

func (c *ClientImpl) SemanticConceptSearch(conceptType, concept string) ([]*SemanticConceptArticle, error) {
Expand All @@ -58,11 +58,11 @@ func (c *ClientImpl) SemanticConceptSearch(conceptType, concept string) ([]*Sema
}

err = json.Unmarshal(rawRes, &res)
if len(res.Result) == 0 {
if len(res.Results) == 0 {
return nil, errors.New("no results")
}

return res.Result[0].ArticleList.Result, nil
return res.Results[0].ArticleList.Results, nil
}

func (c *ClientImpl) do(uri string) (body []byte, err error) {
Expand Down
75 changes: 42 additions & 33 deletions examples/nyt/mostpopular.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/nyt/mostpopular.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ message MostPopularResponse {
string status = 1;
string copyright = 2;
uint32 num_results = 3;
repeated MostPopularResult result = 4;
repeated MostPopularResult results = 4;
}

message MostPopularResult {
Expand Down
54 changes: 28 additions & 26 deletions examples/nyt/semanticconcept.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/nyt/semanticconcept.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ message SemanticConceptResponse {
string status = 1;
string copyright = 2;
uint32 num_results = 3;
repeated SemanticConceptResult result = 4;
repeated SemanticConceptResult results = 4;
}

message SemanticConceptResult {
SemanticConceptArticleList article_list = 1;
}

message SemanticConceptArticleList {
repeated SemanticConceptArticle result = 1;
repeated SemanticConceptArticle results = 1;
uint32 total = 2;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/servers/rpc/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
)

func main() {
conn, err := grpc.Dial(*serverAddr)
conn, err := grpc.Dial(*serverAddr, grpc.WithInsecure())
if err != nil {
grpclog.Fatalf("fail to dial: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions server/rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (r *RPCServer) Start() error {
return err
}

func() {
go func() {
if err := r.srvr.Serve(rl); err != nil {
Log.Error("encountered an error while serving RPC listener: ", err)
}
Expand All @@ -130,8 +130,8 @@ func (r *RPCServer) Start() error {
return err
}

func() {
if err := srv.Serve(rl); err != nil {
go func() {
if err := srv.Serve(hl); err != nil {
Log.Error("encountered an error while serving listener: ", err)
}
}()
Expand Down

0 comments on commit f5b781a

Please sign in to comment.