-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Feature request: Support multiple packages in gRPC microservice #1640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
proto filesHere're more sample codes.
// entitiy.proto
syntax = "proto3";
package entity;
enum Currency {
USD = 0;
}
message Product {
string id = 1;
string slug = 2;
string name = 3;
string description = 4;
Currency currency = 5;
int32 price = 6;
}
message Order {
string id = 1;
string subject = 2;
string body = 3;
int32 totalPrice = 4;
Currency currency = 5;
string channel = 6;
} // entitiy.proto
syntax = "proto3";
import "../common/entity.proto";
package product;
service ProductService {
rpc FindOne (ProductRequest) returns (ProductResponse) {}
rpc CreateOne (CreateProductRequest) returns (CreateProductResponse) {}
rpc FindByCategory (ProductByCategoryRequest) returns (ProductByCategoryResponse) {}
}
message ProductRequest {
string slug = 1;
}
message ProductResponse {
entity.Product product = 3;
}
message CreateProductRequest {
string slug = 1;
string name = 2;
int32 price = 3;
Currency currency = 4;
string description = 5;
string categorySlug = 6;
}
message CreateProductResponse {
string productId = 3;
}
message ProductByCategoryRequest {
string categorySlug = 1;
}
message ProductByCategoryResponse {
repeated entity.Product products = 1;
} // order.proto
syntax = "proto3";
import "../common/entity.proto";
package order;
service OrderService {
rpc FindOne (OrderRequest) returns (OrderResponse) {}
rpc FindByUser (OrderByUserRequest) returns (OrderByUserResponse) {}
rpc CreateOne (CreateOrderRequest) returns (CreateOrderResponse) {}
}
message OrderRequest {
string id = 1;
}
message OrderResponse {
entity.Order order = 1;
}
message OrderByUserRequest {
string userId = 1;
}
message OrderByUserResponse {
repeated entity.Order order = 1;
}
message CreateOrderRequest {
}
message CreateOrderResponse {
entity.Order order = 1;
} // ./payment.proto
syntax = "proto3";
import "./modules/product.proto";
import "./modules/order.proto";
package payment;
message None {} |
Thanks for reporting @zry656565! Would you like to create a PR? |
in 5.7.4 |
@kamilmysliwiec I created a related PR, please have a look when u'r free. |
@kamilmysliwiec What is the state of this feature request? What can I do to help? I am using Nestjs to create a microservices ecosystem using gRPC but I am stuck with this issue. I need every gRPC service to run along with a gRPC health check service on the same port using different proto files. Example: account.session.v1.proto
grpc.health.v1.proto syntax = "proto3";
package account.session.v1;
service SessionService {
rpc FindAll(SessionFindAllRequest) returns (SessionFindAllResponse);
}
message Session {
int32 id = 1;
string token = 2;
}
message SessionFindAllRequest {}
message SessionFindAllResponse { repeated Session sessions = 1; } syntax = "proto3";
package grpc.health.v1;
message HealthCheckRequest { string service = 1; }
message HealthCheckResponse {
enum ServingStatus {
UNKNOWN = 0;
SERVING = 1;
NOT_SERVING = 2;
}
ServingStatus status = 1;
}
service Health {
rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse);
} I will be using Kubernetes so I need to use terminus to do health checking. I have time to contribute to this because I like Nestjs and want to use it in production at my new startup. This is the non-breaking solution I am proposing: app.connectMicroservice({
transport: Transport.GRPCMultiplePackages,
options: {
url: 'localhost:5000',
services: [
{
package: 'account.session.v1',
protoPath: 'account.session.v1.proto',
},
{
package: 'grpc.health.v1',
protoPath: 'grpc.health.v1.proto',
},
],
},
}); |
+1 |
2 similar comments
+1 |
+1 |
+1 |
1 similar comment
+1 |
Before the PR get merged, I created a pacakge: |
Published as 6.11.0. More information here #3418 |
I'm submitting a...
Current behavior
Currently, I setup a gRPC microservice, and created several packages in protobuf files. But it didn't work.
Cause there's only a little of documents about gRPC in Nest, so I read some Nest codes about gPRC server initialization:
nest/packages/microservices/server/server-grpc.ts
Lines 53 to 74 in bf04704
What I found is that there's only one package that I could config in
GrpcOptions
. ONLY ONE. It does no good to construct my*.proto
files in a well structure.Minimal reproduction of the problem with instructions
Sample codes are like below:
Expected behavior
I need to configure several packages when setup the server, like this:
What is the motivation / use case for changing the behavior?
I need to separate individual services into different proto files (different packages).
Environment
The text was updated successfully, but these errors were encountered: