gogo / letmegrpc

[maintainer wanted] generates a web form gui from a grpc specification
BSD 3-Clause "New" or "Revised" License
419 stars 50 forks source link

letmegrpc doesn't support Google's Message Types #57

Open aalhour opened 4 years ago

aalhour commented 4 years ago

I get the following error when I try to generate a GUI with letmegrpc:

2019/11/16 14:14:37 google/protobuf/any.proto: File not found.
google/protobuf/descriptor.proto: File not found.
google/protobuf/timestamp.proto: File not found.
todo_list.proto: Import "google/protobuf/any.proto" was not found or had errors.
todo_list.proto: Import "google/protobuf/descriptor.proto" was not found or had errors.
todo_list.proto: Import "google/protobuf/timestamp.proto" was not found or had errors.
todo_list.proto:58:5: "google.protobuf.Timestamp" is not defined.
todo_list.proto:59:5: "google.protobuf.Timestamp" is not defined.
todo_list.proto:60:5: "google.protobuf.Timestamp" is not defined.
todo_list.proto:72:5: "google.protobuf.Timestamp" is not defined.
todo_list.proto:73:5: "google.protobuf.Timestamp" is not defined.
todo_list.proto:74:5: "google.protobuf.Timestamp" is not defined.
todo_list.proto:87:5: "google.protobuf.Timestamp" is not defined.
todo_list.proto:88:5: "google.protobuf.Timestamp" is not defined.
todo_list.proto:89:5: "google.protobuf.Timestamp" is not defined.
todo_list.proto:104:5: "google.protobuf.Timestamp" is not defined.
todo_list.proto:105:5: "google.protobuf.Timestamp" is not defined.
todo_list.proto:106:5: "google.protobuf.Timestamp" is not defined.
todo_list.proto:150:5: "google.protobuf.FileDescriptorSet" is not defined.
todo_list.proto:153:5: "google.protobuf.Any" is not defined.
 exit status 1

Check the original proto schema below for more details about the message types.

Original Proto Document:

syntax = "proto3";

import "google/protobuf/any.proto";
import "google/protobuf/descriptor.proto";
import "google/protobuf/timestamp.proto";

/*
 * Services
 */
service TodoList {
    // Gets a todo item by id
    rpc GetItem (GetItemReq) returns (GetItemResp) {}

    // Adds a new item to the todo list
    rpc AddItem (AddItemReq) returns (AddItemResp) {}

    // Updates a todo items task
    rpc UpdateItem (UpdateItemReq) returns (UpdateItemResp) {}

    // Deletes a todo item by id
    rpc DeleteItem (DeleteItemReq) returns (DeleteItemResp) {}

    // Marks a todo item as DONE
    rpc MarkItemAsDone (MarkItemDoneReq) returns (MarkItemDoneResp) {}

    // Marks a todo item as ONGOING
    rpc MarkItemAsOnGoing (MarkItemOnGoingReq) returns (MarkItemOnGoingResp) {}

    // Streams a list of todo items from the server to the client
    rpc GetItemsStream (GetItemsStreamReq) returns (stream GetItemResp) {}

    // Bidirectional streaming RPC where the client streams AddTodoItemRequest
    // messages and the server streams TodoItem responses
    rpc AddItemsSteam (stream AddItemReq) returns (stream AddItemResp) {}
}

/**
 * Messages
 */
enum Priority {
    PRIORITY_UNSPECIFIED = 0;
    PRIORITY_LOW = 1;
    PRIORITY_MEDIUM = 2;
    PRIORITY_HIGH = 3;
}

enum Status {
    STATUS_UNSPECIFIED = 0;
    STATUS_ONGOING = 1;
    STATUS_DONE = 2;
}

message TodoItem {
    string id = 1;
    string task = 2;
    Priority priority = 3;
    Status status = 4;
    google.protobuf.Timestamp created_at = 5;
    google.protobuf.Timestamp updated_at = 6;
    google.protobuf.Timestamp completed_at = 7;
}

message GetItemReq {
    string id = 1;
}

message GetItemResp {
    string id = 1;
    string task = 2;
    Priority priority = 3;
    Status status = 4;
    google.protobuf.Timestamp created_at = 5;
    google.protobuf.Timestamp updated_at = 6;
    google.protobuf.Timestamp completed_at = 7;
}

message AddItemReq {
    string task = 1;
    Priority priority = 2;
}

message AddItemResp {
    string id = 1;
    string task = 2;
    Priority priority = 3;
    Status status = 4;
    google.protobuf.Timestamp created_at = 5;
    google.protobuf.Timestamp updated_at = 6;
    google.protobuf.Timestamp completed_at = 7;
}

message UpdateItemReq {
    string id = 1;
    string task = 2;
    Priority priority = 3;
    Status status = 4;
}

message UpdateItemResp {
    string id = 1;
    string task = 2;
    Priority priority = 3;
    Status status = 4;
    google.protobuf.Timestamp created_at = 5;
    google.protobuf.Timestamp updated_at = 6;
    google.protobuf.Timestamp completed_at = 7;
}

message DeleteItemReq {
    string id = 1;
}

message DeleteItemResp {
    string id = 1;
    bool success = 2;
    string message = 3;
}

message MarkItemDoneReq {
    string id = 1;
}

message MarkItemDoneResp {
    string id = 1;
    bool success = 2;
    string message = 3;
}

message MarkItemOnGoingReq {
    string id = 1;
}

message MarkItemOnGoingResp {
    string id = 1;
    bool success = 2;
    string message = 3;
}

message GetItemsStreamReq {
    int32 limit = 1;
}

message GetItemsStreamResp {
    repeated TodoItem items = 1;
    uint32 cursor = 2;
}

message SelfDescribingMessage {
    // Set of FileDescriptorProtos which describe the type and its dependencies.
    google.protobuf.FileDescriptorSet descriptor_set = 1;

    // The message and its type, encoded as an Any message.
    google.protobuf.Any message = 2;
}
awalterschulze commented 4 years ago

What did you run and have you tried playing around with your proto_path

Having any imports with put you in the customization section https://github.com/gogo/letmegrpc#customization

aalhour commented 4 years ago

This is the command I ran: letmegrpc --addr=localhost:50051 --port=8080 --proto_path=. todo_list.proto

I will give the customization section a look and get back to you with feedback.

Thanks!

aalhour commented 4 years ago

Same error, letmegrpc cannot read the google/protobuf message types:

$ go run todo_list.letmegrpc.go

todo_list.letmegrpc.go:12:2: cannot find package "google/protobuf" in any of:
    /usr/local/go/src/google/protobuf (from $GOROOT)
    /go/src/google/protobuf (from $GOPATH)

Same error happens from within a Docker image:

Successfully built 8237e132b3a9
Successfully tagged todo_list_admin:latest
package todo_list.letmegrpc.proto: cannot find package "todo_list.letmegrpc.proto" in any of:
    /usr/local/go/src/todo_list.letmegrpc.proto (from $GOROOT)
    /go/src/todo_list.letmegrpc.proto (from $GOPATH)

Here's the Dockerfile:

FROM golang:1.13.4-alpine

MAINTAINER aalhour

RUN apk add --update --no-cache \
    git \
    gcc \
    g++ \
    make \
    musl-dev \
    build-base \
    protobuf

# Install letmegrpc
WORKDIR $GOPATH

RUN mkdir -p ./src/github.com/gogo/letmegrpc
RUN git clone https://github.com/gogo/letmegrpc ./src/github.com/gogo/letmegrpc
RUN git clone https://github.com/gogo/protobuf ./src/github.com/gogo/protobuf
RUN go get github.com/gogo/pbparser
RUN go get google.golang.org/grpc
RUN go get golang.org/x/net/context
RUN cd ./src/github.com/gogo/protobuf && make install
RUN cd ./src/github.com/gogo/letmegrpc && make install

# Copy the TodoList Proto Schema document
COPY .protos/todo_list.proto .
RUN protoc -I=. --letmegrpc_out=. --gogo_out=. todo_list.proto

# Run the admin
EXPOSE 50052

ENTRYPOINT ["go", "run", "todo_list.letmegrpc.proto"]
aalhour commented 4 years ago

I tried fixing the problem by copying the google/protobuf directory into the /go/src/ package but it still doesn't work as I believe the letmegrpc is not compiling the proto schema correctly:

... 
... setup letmegrpc
... 

RUN cp -Rp ./src/github.com/gogo/protobuf/protobuf/google ./src/google
RUN cp -Rp ./src/github.com/gogo/protobuf/protobuf/google ./google

# Copy the TodoList Proto Schema document
COPY .protos/todo_list.proto .
RUN protoc -I=. --letmegrpc_out=. --gogo_out=. todo_list.proto

# Run the admin
EXPOSE 50052

ENTRYPOINT ["letmegrpc", "--addr=localhost:50051", "--port=8080", "--proto_path=.", "todo_list.proto"]
letmegrpc --addr=localhost:50051 --port=8080 --proto_path=. todo_list.proto
2019/11/18 12:46:42 ../../todo_list.letmegrpc.go:12:2: no Go files in /go/src/google/protobuf
 exit status 1
aalhour commented 4 years ago

@awalterschulze - any update on your side regarding how to solve this?

awalterschulze commented 4 years ago

I suspect you won't be able to use the letmegrpc directly.

--letmegrpc_out=. looks like the way to go And then you will need to write a small main.go And setup your proto-path correctly That is if I remember correctly

Sorry it has been a while and we are still looking for a maintainer to take over this project.