【发布时间】:2019-11-02 05:37:12
【问题描述】:
我有一个简单的服务,其中包含像
这样的消息定义message BrandAttribute {
option (gorm.opts) = {
ormable: true
};
atlas.rpc.Identifier id = 1 [(gorm.field).tag = {type: "serial" primary_key: true}];
string attribute_key = 2;
string attribute_value = 3;
atlas.rpc.Identifier brand_id = 4 [(gorm.field).tag = {not_null: true}];
Status status = 5;
}
message Brand {
option (gorm.opts) = {
ormable: true
};
atlas.rpc.Identifier id = 1 [(gorm.field).tag = {type: "serial" primary_key: true}];
atlas.rpc.Identifier external_id = 2 [(gorm.field).tag = {type: "text" unique: true}];
string name = 3;
string description = 4;
string keywords = 5;
string meta_keywords = 6;
string meta_description = 7;
repeated BrandAttribute brand_attributes = 8 [(gorm.field).has_many.foreignkey = "brand_id", (gorm.field).has_many.association_foreignkey = "id"];
Status status = 9;
}
我已经定义了在上述定义的实体之上实现 CRUD 操作的服务,但是这些服务接受品牌本身作为创建/更新操作的请求负载(参数),这种方法是否正确?如果这不是实现这一目标的最佳方法。此外,如果我想使用 JDBC 来实现持久性,我将不得不自己装饰 protoc 在 protobuf 定义文件中不允许的实体,我该如何实现呢?
【问题讨论】:
标签: protocol-buffers microservices grpc grpc-java