Reputation: 33
I tried a Way in using proto files in which
I defined rpc components in proto B in Project B
Exmaple : rpc Line (RequestData) returns (ResponseInfoBase);
I defined message in Proto A which is in project A(different project)
Example : message RequestData { string Data = 1 ; }
message ResponseInfoBase { string Data = 1; } My question is am I able to import ProtoA to ProtoB?
Upvotes: 3
Views: 1185
Reputation: 817
Source Code URL: https://github.com/vishipayyallore/speaker_series/tree/master/GRpcDemos/SimpleGRpcDemo
ForHoldingMessages.csproj This holds only messages.
<ItemGroup>
<Protobuf Include="Protos\greet.proto" GrpcServices="Server" />
<Protobuf Include="Protos\AddressBookMessages.proto" GrpcServices="None" />
</ItemGroup>
College.Service.csproj This holds the rpc method and uses the message defined in ForHoldingMessagaes.csproj.
<ItemGroup>
<Protobuf Include="..\ForHoldingMessages\Protos\AddressBookMessages.proto" GrpcServices="None">
<Link>Protos\AddressBookMessages.proto</Link>
</Protobuf>
<Protobuf Include="Protos\greet.proto" GrpcServices="Server" />
<Protobuf Include="..\College.Service\Protos\AddressBook.proto" GrpcServices="Server" ProtoRoot="..">
</Protobuf>
</ItemGroup>
College.ServiceClient.csproj This is the gRPC Client application which uses the protos from both the projects and invokes the RPC method defined in College.Service.
<ItemGroup>
<Protobuf Include="..\College.Service\Protos\AddressBook.proto" GrpcServices="Client" ProtoRoot="..">
<Link>Protos\AddressBook.proto</Link>
</Protobuf>
<Protobuf Include="..\ForHoldingMessages\Protos\AddressBookMessages.proto" GrpcServices="Client">
<Link>Protos\AddressBookMessages.proto</Link>
</Protobuf>
</ItemGroup>
Image for additional Reference:
Upvotes: 3