Change in Service and message names resulting in rewrite of service in java

11 views
Skip to first unread message

manojii...@gmail.com

unread,
Feb 4, 2020, 9:33:55 AM2/4/20
to grpc.io
Hi,

Below is my sample .proto file content

syntax = "proto3";

package dummy;

option java_package = "com.productservice.shirt";
option java_multiple_files = true;

/* ShirtInfo represents the basic fileds related to the static information
* of shirts */

message ShirtInfo {
    string brand = 1;
    string summary = 2;
    string category = 3;
    map<string, string> specifications = 4;
    repeated string tags = 5;
}

/* ShirtInfo create response. When a new entry is made, returned response will
* be the id of the document. */
message CreateShirtInfoResponse {
    string id = 1;
}

/* ShirtInfo reate request. Refer to the @ShirtInfo message.*/
message CreateShirtInfoRequest{
    ShirtInfo request = 1;
   
}

/* Request object to get the @ShirtInfo based on the id provided.*/
message GetShirtInfoRequest{
    string id = 1;
}

/* Respone object for getting @ShirtInfo based on id*/
message GetShirtInfoResponse{
    ShirtInfo response = 1;
}

/* Request Object to update the existing @ShirtInfo*/
message UpdateShirtInfoRequest{
    ShirtInfo request = 1;
}

/* Response object to the update request @UpdateShirtInfoRequest*/
message UpdateShirtInfoResponse{
    ShirtInfo response = 1;
}

service ShirtStaticInfoService {
    rpc createShirtInfo(CreateShirtInfoRequest) returns (CreateShirtInfoResponse) {};
    rpc getShirtInfo(GetShirtInfoRequest) returns (GetShirtInfoResponse){};
    rpc updateShirtInfo(UpdateShirtInfoRequest) returns (UpdateShirtInfoResponse){};
}

With the above .proto file, i have generated java files and implemented server side Service. Now  I have made changes in the name of the service say from ShirtStaticInfoService to ShirtInfoService and generate the respective java files. To incorporate these changes in my Server side Service, I need to first comment out the code, build and then apply the changes. So, is there any way where the changes would automatically updated if there are any changes in .proto file. 

Any help or reference would be greatly appreciated.

Regards
Manoj  

Danesh Kuruppu

unread,
Feb 4, 2020, 11:42:50 AM2/4/20
to manojii...@gmail.com, grpc.io
Hi Manoj,

AFAIK there is no way to automatically change your service code to comply with the proto definition changes. If you are creating your java project using a build tool like maven, gradle, bazel, It will generate the source code each time you build the project for the proto definition. But you still need to change your service code to comply with the proto definition changes.

Thanks
Danesh

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/ce8e81e3-e815-4f8c-9398-8fa817c4446b%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages