让我们以官方文档中的这个例子为例:
// Updates a book.
rpc UpdateBook(UpdateBookRequest) returns (Book) {
// Update maps to HTTP PATCH. Resource name is mapped to a URL path.
// Resource is contained in the HTTP request body.
option (google.api.http) = {
// Note the URL template variable which captures the resource name of the
// book to update.
patch: "/v1/{book.name=shelves/*/books/*}"
body: "book"
};
}
message UpdateBookRequest {
// The book resource which replaces the resource on the server.
Book book = 1;
// The update mask applies to the resource. For the `FieldMask` definition,
// see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
FieldMask update_mask = 2;
}
如果我没有 grpc 网关并且只使用 grpc,我可以这样使用掩码吗:
// Updates a book.
rpc UpdateBook(UpdateBookRequest) returns (Book);
message UpdateBookRequest {
// The book resource which replaces the resource on the server.
Book book = 1;
// The update mask applies to the resource. For the `FieldMask` definition,
// see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
FieldMask update_mask = 2;
}
如果是这样,该掩码应该如何工作 - 过滤器请求?或在数据库保存期间应用,它如何知道数据库......所以我对使用它有点困惑。在我自己的 grpc 示例中,我看到掩码不会过滤请求。