func (i *Invocation) ShowCategories() error { var c *client.Client var res *rpcpb.GetCategoryResponse // Run it on files c, _, cleanup, err := i.startServices() defer cleanup() if err != nil { return fmt.Errorf("HTTP client did not become healthy: %v", err) } glog.Infof("Calling to get the categories") err = c.Call("/ShipshapeService/GetCategory", &rpcpb.GetCategoryRequest{}, &res) if err != nil { fmt.Errorf("Could not get categories: %v", err) return err } fmt.Println(strings.Join(res.Category, "\n")) return nil }
func analyze(c *client.Client, req *rpcpb.ShipshapeRequest, originalDir string, handleResponse func(msg *rpcpb.ShipshapeResponse, directory string) error) (int, error) { var totalNotes = 0 glog.Infof("Calling to the shipshape service with %v", req) rd := c.Stream("/ShipshapeService/Run", req) defer rd.Close() for { var msg rpcpb.ShipshapeResponse if err := rd.NextResult(&msg); err == io.EOF { break } else if err != nil { return 0, fmt.Errorf("received an error from calling run: %v", err.Error()) } err := handleResponse(&msg, originalDir) if err != nil { return 0, fmt.Errorf("could not parse results: %v", err.Error()) } totalNotes += numNotes(&msg) } return totalNotes, nil }