{"id":279229,"date":"2023-08-15T09:00:18","date_gmt":"2023-08-15T01:00:18","guid":{"rendered":"https:\/\/gulass.cn\/?p=279229"},"modified":"2023-08-12T23:00:33","modified_gmt":"2023-08-12T15:00:33","slug":"capnproto-1-0-released","status":"publish","type":"post","link":"https:\/\/gulass.cn\/capnproto-1-0-released.html","title":{"rendered":"\u5f00\u6e90\u5341\u5e74\u540e Cap’n Proto 1.0 \u7ec8\u53d1\u5e03\uff0c\u6bd4 Protocol Buffers \u5feb\u592a\u591a"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nCap'n Proto \u662f\u4e00\u79cd\u901f\u5ea6\u6781\u5feb\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f\u548c capability-based RPC \u7cfb\u7edf\uff0c\u4e8e 2013 \u5e74 4 \u6708\u5f00\u6e90\u53d1\u5e03\u3002\u65f6\u81f3\u4eca\u65e5\uff0cCap'n Proto 1.0 \u7ec8\u4e8e\u53d1\u5e03\uff0c\u8fd9\u662f\u4e00\u4e2a\u957f\u671f\u652f\u6301\u7248\u672c\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

Cap'n Proto \u662f\u4e00\u79cd\u901f\u5ea6\u6781\u5feb\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f\u548c capability-based RPC \u7cfb\u7edf\uff0c\u4e8e 2013 \u5e74 4 \u6708\u5f00\u6e90\u53d1\u5e03\u3002\u65f6\u81f3\u4eca\u65e5\uff0cCap'n Proto 1.0 \u7ec8\u4e8e\u53d1\u5e03\uff0c\u8fd9\u662f\u4e00\u4e2a\u957f\u671f\u652f\u6301\u7248\u672c\u3002<\/p>\n

Cap'n Proto \u9879\u76ee\u4f5c\u8005\u662f Kenton Varda \u2014\u2014 Protocol Buffers version 2 \u7684\u4e3b\u8981\u5f00\u53d1\u8005\u3002\u4ed6\u8868\u793a\uff0cCap'n Proto \u662f\u5176\u591a\u5e74\u6765\u5f00\u53d1 Protobufs\u3001\u542c\u53d6\u7528\u6237\u53cd\u9988\u5e76\u6c72\u53d6\u7ecf\u9a8c\u601d\u8003\u53cd\u601d\u540e\u7684\u6210\u679c\u7ed3\u6676\u3002<\/p>\n

\u76ee\u524d\u4ed6\u5df2\u79bb\u5f00\u8c37\u6b4c\uff0c\u56e0\u6b64 \u201cCap'n Proto \u4e0d\u96b6\u5c5e\u4e8e\u8c37\u6b4c\uff0c\u4e5f\u4ece\u672a\u96b6\u5c5e\u4e8e\u8c37\u6b4c\u201d\u3002\u57fa\u51c6\u6d4b\u8bd5\u7ed3\u679c\u8868\u660e\uff0cCap'n Proto \u6bd4 Protocol Buffers \u5feb\u65e0\u9650\u500d\u3002<\/p>\n

\"\"<\/p>\n

\u81ea\u4e0a\u4e00\u4e2a\u7248\u672c v0.10 \u4ee5\u6765\uff0c\u65b0\u7248\u672c\u7684\u4e00\u4e9b\u4eae\u70b9\u5185\u5bb9\u5305\u62ec\uff1a<\/p>\n

  • \u9488\u5bf9 Cap'n Proto RPC \u6027\u80fd\u7684\u4e00\u7cfb\u5217\u4f18\u5316\u3002\u5176\u4e2d\u5305\u62ec\u51cf\u5c11 RPC \u5b9e\u73b0\u548c KJ I\/O \u6846\u67b6\u7684\u5185\u5b58\u5206\u914d\u91cf\uff0c\u589e\u52a0\u4ece RPC \u534f\u8bae\u4e2d\u7701\u7565\u67d0\u4e9b\u4fe1\u606f\u4ee5\u51cf\u5c11\u6d41\u91cf\u7684\u529f\u80fd\uff0c\u4ee5\u53ca\u66f4\u597d\u5730\u7f13\u51b2\u4e00\u8d77\u53d1\u9001\u548c\u63a5\u6536\u7684\u5c0f\u4fe1\u606f\u4ee5\u51cf\u5c11\u7cfb\u7edf\u8c03\u7528\u3002<\/li>\n
  • Breaking change\uff1a \u5728\u6b64\u4e4b\u524d\uff0c\u670d\u52a1\u5668\u53ef\u5728\u8c03\u7528\u5b8c\u6210\u540e\u8c03\u7528 context.allowCancellation ()\uff0c\u9009\u62e9\u5141\u8bb8\u53d6\u6d88 RPC\u3002\u5728 1.0 \u7248\u4e2d\uff0c\u9009\u62e9\u53d6\u6d88 RPC \u53ef\u901a\u8fc7\u6a21\u5f0f\u6ce8\u89e3\uff08c++.capnp \u4e2d\u5b9a\u4e49\u7684 allowCancellation \u6ce8\u89e3\uff09\u6765\u5b9e\u73b0\uff1b\u6a21\u5f0f\u7ea7\u6ce8\u89e3\u53ef\u4ee5\u4e00\u6b21\u5bf9\u6574\u4e2a\u6587\u4ef6\u8fdb\u884c\u8bbe\u7f6e\u3002\u6b64\u5916\uff0c\u52a8\u6001\u9009\u62e9\u52a0\u5165\u9700\u8981\u5927\u91cf\u7684\u7c3f\u8bb0\u5de5\u4f5c\uff0c\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\u4f1a\u5bf9\u6027\u80fd\u4ea7\u751f\u660e\u663e\u5f71\u54cd\uff1b\u800c\u6539\u7528\u6ce8\u91ca\u5219\u80fd\u63d0\u9ad8\u6027\u80fd\u3002\u5bf9\u4e8e\u4ece\u672a\u4f7f\u7528 context.allowCancellation () \u7684\u7528\u6237\u6765\u8bf4\uff0c\u5347\u7ea7\u5230 1.0 \u7248\u65f6\u65e0\u9700\u505a\u4efb\u4f55\u66f4\u6539\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4ecd\u4e0d\u5141\u8bb8\u53d6\u6d88\u3002(\u5982\u679c\u53d7\u5230\u5f71\u54cd\uff0c\u4f60\u5c06\u770b\u5230\u7f16\u8bd1\u9519\u8bef\u3002\u5982\u679c\u6ca1\u6709\u7f16\u8bd1\u9519\u8bef\uff0c\u5219\u65e0\u9700\u62c5\u5fc3\uff09\u3002<\/li>\n
  • KJ \u73b0\u5728\u5728\u6709 kqueue () \u7684\u7cfb\u7edf\uff08MacOS \u548c BSD \u884d\u751f\u7248\u672c\uff09\u4e0a\u4f7f\u7528\u5b83\u6765\u5904\u7406\u5f02\u6b65 I\/O\u3002\u5728 Linux \u4e0a\uff0cKJ \u4e00\u76f4\u4f7f\u7528 epoll\uff0c\u4f46\u5728\u5176\u4ed6\u7c7b Unix \u5e73\u53f0\u4e0a\uff0cKJ \u4e00\u76f4\u4f7f\u7528\u8f83\u6162\u7684 poll ()-based \u65b9\u6cd5\u3002<\/li>\n
  • KJ \u7684 HTTP \u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u5b9e\u73b0\u73b0\u5728\u652f\u6301 CONNECT \u65b9\u6cd5\u3002<\/li>\n
  • \u5f15\u5165\u4e86\u4e00\u4e2a\u65b0\u7c7b capnp::RevocableServer\uff0c\u4ee5\u5e2e\u52a9\u5728\u751f\u547d\u5468\u671f\u4e0d\u53d7\u5305\u88c5\u5668\u63a7\u5236\u7684\u5bf9\u8c61\u5468\u56f4\u5bfc\u51fa RPC \u5305\u88c5\u5668\u3002<\/li>\n
  • \u4ee5\u53ca\u4e00\u4e9b\u66f4\u5c0f\u7684 bug \u4fee\u590d\u548c\u6539\u8fdb\u3002\u8be6\u60c5\u53ef\u53c2\u9605 PR \u5386\u53f2\u8bb0\u5f55\u3002<\/li>\n

    \u5728 1.0 \u7248\u672c\u53d1\u5e03\u540e\uff0c2.0 \u7248\u672c\u7684\u5de5\u4f5c\u4e5f\u5f00\u59cb\u63d0\u4e0a\u65e5\u7a0b\u3002\u6839\u636e\u89c4\u5212\uff0cv2.0 \u65e8\u5728\u5bf9 Cap'n Proto \u7684 C++ API \u53ca\u5176\u914d\u5957\u7684 KJ C++ \u5de5\u5177\u5305\u5e93\u505a\u51fa\u4e00\u4e9b\u6539\u53d8\uff1b\u4ee5\u53ca\u505a\u4e00\u4e9b\u5168\u9762\u7684\u5411\u540e\u517c\u5bb9\u6539\u52a8\u4ee5\u4fee\u590d\u4e00\u4e9b\u95ee\u9898\uff0c\u5e76\u6539\u5584\u56e2\u961f\u4e2d\u5f00\u53d1\u4eba\u5458\u7684\u4f53\u9a8c\u3002\u76ee\u524d\u7684\u4e00\u4e9b\u60f3\u6cd5\u5305\u62ec\uff1a<\/p>\n

  • \u9700\u8981\u4e00\u4e2a\u652f\u6301 C++20 \u751a\u81f3 C++23 \u7684\u7f16\u8bd1\u5668\u3002Cap'n Proto 1.0 \u4ec5\u9700\u8981 C++14\u3002<\/li>\n
  • \u9700\u8981\u4e00\u4e2a\u652f\u6301 C++20 \u534f\u7a0b\u7684\u7f16\u8bd1\u5668\u3002<\/li>\n
  • Cap'n Proto \u7684 RPC \u5e94\u7528\u7a0b\u5e8f\u63a5\u53e3\u3001KJ \u7684 HTTP \u5e94\u7528\u7a0b\u5e8f\u63a5\u53e3\u548c\u5176\u4ed6\u7a0b\u5e8f\u63a5\u53e3\u5f88\u53ef\u80fd\u4f1a\u8fdb\u884c\u4fee\u6539\uff0c\u4f7f\u5176\u66f4\u52a0\u7684 coroutine-friendly\u3002<\/li>\n
  • kj::Maybe \u5c06\u53d8\u5f97\u66f4\u7b26\u5408\u4eba\u4f53\u5de5\u5b66\u3002\u5b83\u5c06\u4e0d\u518d\u91cd\u8f7d nullptr \u6765\u8868\u793a\u503c\u7684\u7f3a\u5931\uff0c\u5c06\u5f15\u5165 kj::none \u6765\u4ee3\u66ff\u3002KJ_IF_MAYBE \u5c06\u4e0d\u518d\u751f\u6210\u6307\u9488\uff0c\u800c\u662f\u4e00\u4e2a\u5f15\u7528\uff08\u8fd9\u662f\u5229\u7528 C++17 \u7279\u6027\u5b9e\u73b0\u7684\u4e00\u79cd\u6280\u5de7\uff09\u3002<\/li>\n
  • \u5c06\u653e\u5f03\u5bf9\u7981\u7528\u5f02\u5e38\u60c5\u51b5\u4e0b\u7684\u7f16\u8bd1\u7684\u652f\u6301\u3002<\/li>\n
  • \u5c06\u653e\u5f03\u5bf9 no-RTTI \u6a21\u5f0f\u548c\u5176\u4ed6\u4f1a\u9020\u6210\u7ef4\u62a4\u8d1f\u62c5\u7684\u7279\u6b8a\u6a21\u5f0f\u7684\u652f\u6301\u3002<\/li>\n
  • \u53ef\u80fd\u4f1a\u4fee\u6539 KJ \u7684\u5f15\u7528\u8ba1\u6570\u65b9\u6cd5\uff0c\u56e0\u4e3a\u76ee\u524d\u7684\u8bbe\u8ba1\u5df2\u88ab\u8bc1\u660e\u5bf9\u8bb8\u591a\u7528\u6237\u6765\u8bf4\u5e76\u4e0d\u76f4\u89c2\u3002<\/li>\n
  • \u5c06\u4fee\u590d kj::AsyncOutputStream \u4e2d\u4e00\u4e2a\u957f\u671f\u5b58\u5728\u7684\u8bbe\u8ba1\u7f3a\u9677\uff0c\u76ee\u524d EOF \u4fe1\u53f7\u662f\u901a\u8fc7\u9500\u6bc1\u6d41\u6765\u53d1\u51fa\u7684\u3002\u53d6\u800c\u4ee3\u4e4b\u7684\u662f\u5c06\u6dfb\u52a0\u4e00\u4e2a\u8fd4\u56de Promise \u7684\u663e\u5f0f end () \u65b9\u6cd5\u3002\u5728\u4e0d\u8c03\u7528 end () \u7684\u60c5\u51b5\u4e0b\u9500\u6bc1\u6570\u636e\u6d41\u5c06\u53d1\u51fa\u9519\u8bef\u7684\u65ad\u5f00\u4fe1\u53f7\u3002(\u8fd8\u60f3\u5bf9 KJ \u6d41 API \u8fdb\u884c\u5176\u4ed6\u4e00\u4e9b\u7f8e\u89c2\u6539\u8fdb\uff09\u3002<\/li>\n
  • \u91cd\u65b0\u8bbe\u8ba1\u51e0\u4e2a\u6838\u5fc3 I\/O API\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u9002\u5e94 Linux \u65b0\u7684 io_uring \u4e8b\u4ef6\u901a\u77e5\u8303\u5f0f\u3002<\/li>\n
  • RPC \u5b9e\u73b0\u53ef\u80fd\u4f1a\u6539\u4e3a\u9ed8\u8ba4\u5141\u8bb8\u53d6\u6d88\u3002<\/li>\n

    \u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u76ee\u524d\u8fd8\u6ca1\u6709\u8ba1\u5212\u5bf9\u5e8f\u5217\u5316\u683c\u5f0f\u6216 RPC \u534f\u8bae\u8fdb\u884c\u4efb\u4f55\u5411\u540e\u4e0d\u517c\u5bb9\u7684\u66f4\u6539\u3002\u6240\u8ba8\u8bba\u7684\u66f4\u6539\u4ec5\u5f71\u54cd C++ API\u3002\u7528\u5176\u4ed6\u8bed\u8a00\u7f16\u5199\u7684\u5e94\u7528\u7a0b\u5e8f\u5b8c\u5168\u4e0d\u53d7\u8fd9\u4e00\u5207\u7684\u5f71\u54cd\u3002<\/p>\n

    \u6b63\u5f0f\u7684 2.0 \u7248\u672c\u77ed\u65f6\u95f4\u5185\u4e0d\u4f1a\u63a8\u51fa\u53d1\u5e03\uff0c\u6216\u8bb8\u4e5f\u8981\u7b49\u4e0a\u51e0\u5e74\u3002<\/p>\n

    \u66f4\u591a\u8be6\u60c5\u53ef\u67e5\u770b\u5b98\u65b9\u516c\u544a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    Cap’n Proto \u662f\u4e00\u79cd\u901f\u5ea6\u6781\u5feb\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f\u548c capability-based RPC \u7cfb\u7edf\uff0c\u4e8e 2 […]<\/p>\n","protected":false},"author":1898,"featured_media":279232,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-279229","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/279229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1898"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=279229"}],"version-history":[{"count":2,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/279229\/revisions"}],"predecessor-version":[{"id":279963,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/279229\/revisions\/279963"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/279232"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=279229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=279229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=279229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}