热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

ProtobufFieldMask可以应用于grpc唯一案例吗?

如何解决《ProtobufFieldMask可以应用于grpc唯一案例吗?》经验,请帮忙看看怎么搞?

让我们从官方文档中拿这个例子:

// 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,我可以这样使用mask:

// 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;
}

如果是这样,该掩码应如何工作 - 过滤请求?或者在db保存期间应用它以及它如何知道db ...所以我对使用它有点困惑.在我自己的grpc示例中,我看到该掩码不会过滤请求.


推荐阅读
author-avatar
霓Nin氵ini
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有