{"@attributes":{"version":"2.0"},"channel":{"title":"ipfans's Blog","link":"https:\/\/www.4async.com\/","description":"Recent content on ipfans's Blog","generator":"Hugo -- gohugo.io","language":"en","lastBuildDate":"Sat, 31 May 2025 20:30:00 +0000","item":[{"title":"\u7a0b\u5e8f\u5458\u7684\u63d0\u793a\u5de5\u7a0b\u624b\u518c","link":"https:\/\/www.4async.com\/2025\/05\/prompt-engineering-playbook-for-programmers\/","pubDate":"Sat, 31 May 2025 20:30:00 +0000","guid":"https:\/\/www.4async.com\/2025\/05\/prompt-engineering-playbook-for-programmers\/","description":"<img src=\"https:\/\/www.4async.com\/2025\/05\/prompt-engineering-playbook-for-programmers\/cover.webp\" alt=\"Featured image of post \u7a0b\u5e8f\u5458\u7684\u63d0\u793a\u5de5\u7a0b\u624b\u518c\" \/><blockquote>\n<p>\u539f\u6587\u6765\u81ea\u4e8e Addy Osmani\uff0c\u4ed6\u662f Google Chrome \u7684\u5de5\u7a0b\u4e3b\u7ba1\uff0c\u5728 Google \u5de5\u4f5c\u591a\u5e74\u3002<\/p><\/blockquote>\n<p>\u5f00\u53d1\u4eba\u5458\u8d8a\u6765\u8d8a\u4f9d\u8d56 AI \u7f16\u7a0b\u52a9\u624b\u6765\u52a0\u901f\u6211\u4eec\u7684\u65e5\u5e38\u5de5\u4f5c\u6d41\u7a0b\u3002\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u81ea\u52a8\u5b8c\u6210\u51fd\u6570\u3001\u5efa\u8bae\u4fee\u590d\u9519\u8bef\uff0c\u751a\u81f3\u751f\u6210\u6574\u4e2a\u6a21\u5757\u6216 MVP\u3002\u7136\u800c\uff0c\u6b63\u5982\u6211\u4eec\u8bb8\u591a\u4eba\u6240\u4e86\u89e3\u7684\u90a3\u6837\uff0cAI \u8f93\u51fa\u7684\u8d28\u91cf\u5f88\u5927\u7a0b\u5ea6\u4e0a\u53d6\u51b3\u4e8e\u4f60\u63d0\u4f9b\u7684\u63d0\u793a\u7684\u8d28\u91cf\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u63d0\u793a\u5de5\u7a0b\u5df2\u7ecf\u6210\u4e3a\u4e00\u9879\u5fc5\u5907\u6280\u80fd\u3002\u4e00\u4e2a\u63aa\u8f9e\u4e0d\u5f53\u7684\u8bf7\u6c42\u53ef\u80fd\u4f1a\u4ea7\u751f\u4e0d\u76f8\u5173\u6216\u7b3c\u7edf\u7684\u7b54\u6848\uff0c\u800c\u4e00\u4e2a\u7cbe\u5fc3\u8bbe\u8ba1\u7684\u63d0\u793a\u53ef\u4ee5\u4ea7\u751f\u5468\u5230\u3001\u51c6\u786e\u751a\u81f3\u5bcc\u6709\u521b\u9020\u6027\u7684\u4ee3\u7801\u89e3\u51b3\u65b9\u6848\u3002\u672c\u6587\u5c06\u5b9e\u9645\u63a2\u8ba8\u5982\u4f55\u7cfb\u7edf\u5730\u6784\u5efa\u9002\u7528\u4e8e\u5e38\u89c1\u5f00\u53d1\u4efb\u52a1\u7684\u63d0\u793a\u3002<\/p>\n<p>AI \u7ed3\u5bf9\u7a0b\u5e8f\u5458\u5f88\u5f3a\u5927\u4f46\u5e76\u975e\u795e\u5947\u2014\u2014\u9664\u4e86\u4f60\u544a\u8bc9\u4ed6\u4eec\u7684\u6216\u5305\u542b\u5728\u4e0a\u4e0b\u6587\u4e2d\u7684\u4fe1\u606f\u5916\uff0c\u5bf9\u4f60\u7279\u5b9a\u7684\u9879\u76ee\u6216\u610f\u56fe\u6ca1\u6709\u5148\u9a8c\u77e5\u8bc6\u3002\u4f60\u63d0\u4f9b\u7684\u4fe1\u606f\u8d8a\u591a\uff0c\u8f93\u51fa\u5c31\u8d8a\u597d\u3002\u6211\u4eec\u5c06\u63d0\u70bc\u51fa\u5f00\u53d1\u8005\u53cd\u54cd\u70ed\u70c8\u7684\u63d0\u793a\u6a21\u5f0f\u3001\u53ef\u91cd\u590d\u7684\u6846\u67b6\u548c\u96be\u5fd8\u7684\u793a\u4f8b\u3002\u4f60\u5c06\u770b\u5230\u597d\u4e0e\u574f\u63d0\u793a\u7684\u5e76\u6392\u6bd4\u8f83\u4ee5\u53ca\u5b9e\u9645\u7684 AI \u54cd\u5e94\uff0c\u5e76\u9644\u6709\u8bc4\u8bba\u4ee5\u4e86\u89e3\u4e3a\u4ec0\u4e48\u4e00\u4e2a\u6210\u529f\u800c\u53e6\u4e00\u4e2a\u5931\u8d25\u3002\u4ee5\u4e0b\u662f\u5165\u95e8\u5c0f\u8d34\u58eb\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u6280\u5de7<\/th>\n<th>\u63d0\u793a\u6a21\u677f<\/th>\n<th>\u76ee\u7684<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1. \u89d2\u8272\u63d0\u793a<\/td>\n<td>\u201c\u4f60\u662f\u4e00\u540d\u8d44\u6df1\u7684{\u8bed\u8a00\u540d}\u5f00\u53d1\u8005\u3002\u8bf7\u5ba1\u67e5\u8fd9\u4e2a\u51fd\u6570\u4ee5\u5b9e\u73b0{\u76ee\u6807}\u3002\u201d<\/td>\n<td>\u6a21\u62df\u4e13\u5bb6\u7ea7\u7684\u4ee3\u7801\u5ba1\u67e5\u3001\u8c03\u8bd5\u6216\u91cd\u6784<\/td>\n<\/tr>\n<tr>\n<td>2. \u660e\u786e\u4e0a\u4e0b\u6587\u8bbe\u5b9a<\/td>\n<td>\u201c\u95ee\u9898\u5982\u4e0b\uff1a{\u95ee\u9898\u8bf4\u660e}\u3002\u4e0b\u9762\u662f\u4ee3\u7801\u3002\u5b83\u672c\u5e94\u505a\u5230{\u9884\u671f\u884c\u4e3a}\uff0c\u4f46\u5b9e\u9645\u4e0a\u505a\u4e86 {\u5b9e\u9645\u884c\u4e3a}\u3002\u4e3a\u4ec0\u4e48\uff1f\u201d<\/td>\n<td>\u660e\u786e\u6846\u5b9a\u95ee\u9898\uff0c\u907f\u514d\u6cdb\u6cdb\u800c\u8c08\u7684\u56de\u7b54<\/td>\n<\/tr>\n<tr>\n<td>3. \u8f93\u5165\/\u8f93\u51fa\u793a\u4f8b<\/td>\n<td>\u201c\u8fd9\u4e2a\u51fd\u6570\u5728\u8f93\u5165{\u8f93\u5165\u5185\u5bb9}\u65f6\u5e94\u8fd4\u56de{\u9884\u671f\u8f93\u51fa}\u3002\u4f60\u80fd\u7f16\u5199\u6216\u4fee\u590d\u8fd9\u6bb5\u4ee3\u7801\u5417\uff1f\u201d<\/td>\n<td>\u901a\u8fc7\u793a\u4f8b\u5f15\u5bfc AI \u7406\u89e3\u610f\u56fe<\/td>\n<\/tr>\n<tr>\n<td>4. \u8fed\u4ee3\u5206\u6b65<\/td>\n<td>\u201c\u9996\u5148\u751f\u6210\u8fd9\u4e2a\u7ec4\u4ef6\u7684\u9aa8\u67b6\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u6dfb\u52a0\u72b6\u6001\u3002\u7136\u540e\u5904\u7406 API \u8c03\u7528\u3002\u201d<\/td>\n<td>\u5c06\u5927\u4efb\u52a1\u62c6\u89e3\u4e3a\u6b65\u9aa4\uff0c\u907f\u514d\u6a21\u7cca\u6216\u8fc7\u8f7d\u7684\u63d0\u793a<\/td>\n<\/tr>\n<tr>\n<td>5. \u6a21\u62df\u8c03\u8bd5<\/td>\n<td>\u201c\u9010\u884c\u8d70\u67e5\u8fd9\u4e2a\u51fd\u6570\u3002\u53d8\u91cf\u503c\u662f\u4ec0\u4e48\uff1f\u54ea\u91cc\u53ef\u80fd\u51fa\u9519\uff1f\u201d<\/td>\n<td>\u5f15\u5bfc AI \u6a21\u62df\u8fd0\u884c\u65f6\u884c\u4e3a\uff0c\u53d1\u73b0\u9690\u85cf\u7684 bug<\/td>\n<\/tr>\n<tr>\n<td>6. \u529f\u80fd\u84dd\u56fe<\/td>\n<td>\u201c\u6211\u6b63\u5728\u6784\u5efa{\u529f\u80fd\u7279\u6027}\u3002\u9700\u6c42\u5982\u4e0b\uff1a{\u5177\u4f53\u8bf4\u660e}\u3002\u6280\u672f\u6808\u4e3a\uff1a{\u6280\u672f\u6808\u8bf4\u660e}\u3002\u8bf7\u642d\u5efa\u521d\u59cb\u7ec4\u4ef6\u5e76\u89e3\u91ca\u4f60\u7684\u9009\u62e9\u3002\u201d<\/td>\n<td>\u542f\u52a8 AI \u4e3b\u5bfc\u7684\u529f\u80fd\u89c4\u5212\u4e0e\u811a\u624b\u67b6\u642d\u5efa<\/td>\n<\/tr>\n<tr>\n<td>7. \u91cd\u6784\u6307\u5bfc<\/td>\n<td>\u201c\u8bf7\u91cd\u6784\u8fd9\u6bb5\u4ee3\u7801\u4ee5\u63d0\u5347{\u76ee\u6807}\uff0c\u6bd4\u5982\uff08\u5982\uff1a\u53ef\u8bfb\u6027\u3001\u6027\u80fd\u3001\u7b26\u5408\u8bed\u8a00\u4e60\u60ef\u7684\u98ce\u683c\uff09\u3002\u8bf7\u4f7f\u7528\u6ce8\u91ca\u89e3\u91ca\u53d8\u66f4\u3002\u201d<\/td>\n<td>\u8ba9 AI \u7684\u91cd\u6784\u7b26\u5408\u4f60\u7684\u76ee\u6807\uff0c\u800c\u4e0d\u662f\u968f\u610f\u66f4\u52a8<\/td>\n<\/tr>\n<tr>\n<td>8. \u8bf7\u6c42\u66ff\u4ee3\u65b9\u6848<\/td>\n<td>\u201c\u4f60\u80fd\u7528\u51fd\u6570\u5f0f\u98ce\u683c\u91cd\u5199\u8fd9\u6bb5\u4ee3\u7801\u5417\uff1f\u9012\u5f52\u7248\u672c\u4f1a\u662f\u4ec0\u4e48\u6837\uff1f\u201d<\/td>\n<td>\u63a2\u7d22\u591a\u79cd\u5b9e\u73b0\u65b9\u5f0f\uff0c\u6269\u5c55\u5de5\u5177\u7bb1<\/td>\n<\/tr>\n<tr>\n<td>9. \u6a61\u76ae\u9e2d\u8c03\u8bd5<\/td>\n<td>\u201c\u6211\u89c9\u5f97\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u662f\uff1a{\u4f60\u7684\u89e3\u91ca}\u3002\u6211\u9057\u6f0f\u4e86\u4ec0\u4e48\u5417\uff1f\u6709\u6ca1\u6709 bug\uff1f\u201d<\/td>\n<td>\u8ba9 AI \u8d28\u7591\u4f60\u7684\u7406\u89e3\u5e76\u53d1\u73b0\u6f5c\u5728\u95ee\u9898<\/td>\n<\/tr>\n<tr>\n<td>10. \u7ea6\u675f\u951a\u5b9a<\/td>\n<td>\u201c\u8bf7\u907f\u514d\uff08\u4f8b\u5982\uff1a\u9012\u5f52\uff09\uff0c\u5e76\u9075\u5b88\uff08\u4f8b\u5982\uff1aES6 \u8bed\u6cd5\u3001\u65e0\u5916\u90e8\u5e93\uff09\u3002\u4f18\u5316\u65b9\u5411\u4e3a\uff08\u4f8b\u5982\uff1a\u5185\u5b58\uff09\u3002\u8fd9\u662f\u51fd\u6570\u4ee3\u7801\uff1a\u201d<\/td>\n<td>\u9632\u6b62 AI \u8fc7\u5ea6\u53d1\u6325\u6216\u5f15\u5165\u4e0d\u517c\u5bb9\u7684\u6a21\u5f0f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 id=\"\u9ad8\u6548\u4ee3\u7801\u63d0\u793a\u57fa\u7840\">\u9ad8\u6548\u4ee3\u7801\u63d0\u793a\u57fa\u7840\n<\/h2><p>\u5411 AI \u7f16\u7801\u5de5\u5177\u63d0\u793a\u4e0e\u4e0e\u4e00\u4e2a\u975e\u5e38\u6709\u539f\u5219\u3001\u6709\u65f6\u4f1a\u77e5\u8bc6\u6e0a\u535a\u7684\u5408\u4f5c\u8005\u4ea4\u6d41\u6709\u70b9\u50cf\u3002\u4e3a\u4e86\u83b7\u5f97\u6709\u7528\u7684\u7ed3\u679c\uff0c\u60a8\u9700\u8981\u6e05\u695a\u5730\u8bbe\u7f6e\u573a\u666f\uff0c\u5e76\u6307\u5bfc AI \u60a8\u60f3\u8981\u4ec0\u4e48\u4ee5\u53ca\u5982\u4f55\u5b9e\u73b0\u3002<\/p>"},{"title":"AI \u4ea7\u54c1\u7684\u7834\u5c40\u4e4b\u9053\uff1a\u4ee5\u4eba\u4e3a\u672c","link":"https:\/\/www.4async.com\/2024\/12\/human-centered-product-design-with-human-in-the-loop\/","pubDate":"Sun, 29 Dec 2024 22:30:00 +0000","guid":"https:\/\/www.4async.com\/2024\/12\/human-centered-product-design-with-human-in-the-loop\/","description":"<img src=\"https:\/\/www.4async.com\/2024\/12\/human-centered-product-design-with-human-in-the-loop\/cover.webp\" alt=\"Featured image of post AI \u4ea7\u54c1\u7684\u7834\u5c40\u4e4b\u9053\uff1a\u4ee5\u4eba\u4e3a\u672c\" \/><p>\u4f34\u968f\u7740 OpenAI\u3001Anthropic \u7b49\u7b49\u516c\u53f8\u7684\u52aa\u529b\uff0c\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08LLM\uff09\u7684\u6027\u80fd\u4e0d\u65ad\u63d0\u5347\uff0cAI \u4ea7\u54c1\u7684\u5e94\u7528\u573a\u666f\u4e5f\u8d8a\u6765\u8d8a\u5e7f\u6cdb\u3002\u4ece\u53e3\u888b\u91cc\u7684\u667a\u80fd\u52a9\u624b\u5230\u9a70\u9a8b\u672a\u6765\u7684\u81ea\u52a8\u9a7e\u9a76\uff0c\u4ece\u8f85\u52a9\u533b\u7597\u8bca\u65ad\u7684\u6167\u773c\u5230\u6d1e\u5bdf\u5e02\u573a\u98ce\u4e91\u7684\u667a\u8111\uff0cAI \u6b63\u4ee5\u524d\u6240\u672a\u6709\u7684\u901f\u5ea6\u6539\u53d8\u7740\u4e16\u754c\u3002\u4f46\u662f\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u4f1a\u6ce8\u610f\u5230\u4e00\u4e9b\u95ee\u9898\uff0c\u6211\u4eec\u4f1a\u9677\u5165\u201c\u6280\u672f\u81f3\u4e0a\u201d\u7684\u8bef\u533a\uff0c\u8fc7\u5206\u5f3a\u8c03\u6280\u672f\u7684\u5148\u8fdb\u6027\uff0c\u800c\u5ffd\u7565\u4e86\u7528\u6237\u7684\u9700\u6c42\u548c\u4f53\u9a8c\u3002\u8fd9\u5c31\u5bfc\u81f4\u4e86\u5f88\u591a AI \u4ea7\u54c1\u867d\u7136\u6280\u672f\u5148\u8fdb\uff0c\u4f46\u5374\u65e0\u6cd5\u771f\u6b63\u6ee1\u8db3\u7528\u6237\u7684\u9700\u6c42\uff0c\u6700\u7ec8\u65e0\u6cd5\u5b9e\u73b0\u5546\u4e1a\u4ef7\u503c\u3002\u7a76\u5176\u539f\u56e0\uff0c\u8bb8\u591a AI \u7cfb\u7edf\u5728\u4e0e\u4eba\u7c7b\u4ea4\u4e92\u65f6\uff0c\u5e38\u5e38\u9677\u5165**\u201c\u9e21\u540c\u9e2d\u8bb2\u201d\u7684\u7a98\u5883**\u2014\u2014\u5bf9\u4e0a\u4e0b\u6587\u7684\u7406\u89e3\u6349\u895f\u89c1\u8098\uff0c\u96be\u4ee5\u9886\u4f1a\u4eba\u7c7b\u8bed\u8a00\u4e2d\u7684\u5fae\u5999\u542b\u4e49\uff1b\u66f4\u4ee4\u4eba\u62c5\u5fe7\u7684\u662f\u201c\u5e7b\u89c9\u201d\u95ee\u9898\uff0cAI \u715e\u6709\u4ecb\u4e8b\u5730\u7f16\u9020\u7740\u201c\u4e00\u672c\u6b63\u7ecf\u7684\u80e1\u8bf4\u516b\u9053\u201d\uff0c\u8ba9\u7528\u6237\u65e0\u6240\u9002\u4ece\uff1b\u800c\u5728\u7528\u6237\u4f53\u9a8c\u65b9\u9762\uff0c\u8bb8\u591a AI \u4ea7\u54c1\u66f4\u662f\u5dee\u5f3a\u4eba\u610f\uff0c\u673a\u68b0\u5f0f\u7684\u4ea4\u4e92\u548c\u51b0\u51b7\u7684\u754c\u9762\u8ba9\u4eba\u96be\u4ee5\u4ea7\u751f\u4eb2\u8fd1\u611f\u3002\u6709\u4e9b\u65f6\u5019\u6211\u4eec\u6709\u4e9b\u5931\u671b\uff1a<a class=\"link\" href=\"https:\/\/zh.wikipedia.org\/zh-hans\/%E5%B8%95%E7%B4%AF%E6%89%98%E6%B3%95%E5%88%99\" target=\"_blank\" rel=\"noopener\"\n>\u5e15\u7d2f\u6258\u6cd5\u5219<\/a>\uff08\u6216\u8005\u53eb\u505a 28 \u539f\u5219\uff09\uff0c\u4e00\u76f4\u5728\u53d1\u6325\u7740\u795e\u79d8\u7684\u529b\u91cf\u3002<\/p>\n<p>\u629b\u5f00\u6a21\u578b\u5f00\u53d1\u516c\u53f8\u672c\u8eab\u800c\u8a00\uff0c\u9762\u5411\u5ba2\u6237\u7684 AI \u4ea7\u54c1\u7684\u8bbe\u8ba1\u548c\u5f00\u53d1\u662f\u4e00\u4e2a\u590d\u6742\u7684\u8fc7\u7a0b\uff0c\u9700\u8981\u7efc\u5408\u8003\u8651\u6280\u672f\u3001\u5546\u4e1a\u548c\u7528\u6237\u4f53\u9a8c\u7b49\u591a\u4e2a\u65b9\u9762\u3002\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u5982\u4f55\u4fdd\u8bc1\u4ea7\u54c1\u7684\u8d28\u91cf\u548c\u7528\u6237\u4f53\u9a8c\u6210\u4e3a\u4e86\u5173\u952e\u95ee\u9898\u3002\u4f20\u7edf\u7684\u4ea7\u54c1\u8bbe\u8ba1\u65b9\u6cd5\u5f80\u5f80\u662f\u7531\u8bbe\u8ba1\u5e08\u548c\u5de5\u7a0b\u5e08\u7b49\u4e13\u4e1a\u4eba\u5458\u5b8c\u6210\uff0c\u800c\u7528\u6237\u5f80\u5f80\u53ea\u662f\u4ea7\u54c1\u7684\u4f7f\u7528\u8005\u3002\u7136\u800c\uff0c\u968f\u7740 LLM \u7684\u53d1\u5c55\uff0c\u65b0\u7684\u4ea4\u4e92\u5f62\u5f0f\u4e0d\u505c\u7684\u51fa\u73b0\uff0c\u6bd4\u5982\u4e4b\u524d\u7684\u804a\u5929\u4ea7\u54c1\u548c\u8bed\u97f3\u52a9\u624b\u4ea4\u4e92\u4ea7\u54c1\u666e\u904d\u53cd\u9988\u4ea4\u4e92\u611f\u592a\u5dee\u5e76\u4e0d\u5b9e\u7528\u3002\u65b0\u7684\u5b9e\u65f6\u591a\u6a21\u6001\u6a21\u578b\u7684\u51fa\u73b0\uff0c\u8ba9\u8fd9\u4e9b\u53ef\u4ee5\u66f4\u597d\u7684\u7406\u89e3\u7528\u6237\u7684\u9700\u6c42\uff0c\u66f4\u597d\u7684\u6ee1\u8db3\u7528\u6237\u7684\u9700\u6c42\u3002<\/p>\n<p>\u4f46\uff0c\u65e0\u8bba\u5982\u4f55\uff0c\u8981\u5145\u5206\u91ca\u653e AI \u7684\u6f5c\u529b\uff0c\u5fc5\u987b\u5c06\u7528\u6237\u9700\u6c42\u548c\u4f53\u9a8c\u7f6e\u4e8e\u6838\u5fc3\u5730\u4f4d\u3002\u8fd9\u4e0d\u4ec5\u4ec5\u662f\u4e00\u53e5\u53e3\u53f7\uff0c\u66f4\u662f\u4e00\u79cd\u6df1\u523b\u7684\u53d8\u9769\uff0c\u8981\u6c42\u6211\u4eec\u5c06\u7528\u6237\u7684\u9700\u6c42\u3001\u671f\u671b\u548c\u4f53\u9a8c\u7f6e\u4e8e AI \u4ea7\u54c1\u8bbe\u8ba1\u7684\u6700\u6838\u5fc3\u3002\u8fd9\u610f\u5473\u7740\uff0c\u6211\u4eec\u9700\u8981\u50cf\u4eba\u7c7b\u5b66\u5bb6\u4e00\u6837\u53bb\u89c2\u5bdf\u548c\u7406\u89e3\u7528\u6237\u7684\u771f\u5b9e\u8bc9\u6c42\uff0c\u50cf\u5fc3\u7406\u5b66\u5bb6\u4e00\u6837\u53bb\u63e3\u6469\u7528\u6237\u7684\u60c5\u611f\u548c\u8ba4\u77e5\u6a21\u5f0f\uff0c\u5e76\u5c06\u8fd9\u4e9b\u6d1e\u5bdf\u6df1\u6df1\u5730\u70d9\u5370\u5728\u4ea7\u54c1\u7684\u57fa\u56e0\u4e4b\u4e2d\u3002\u53ea\u6709\u8fd9\u6837\uff0c\u624d\u80fd\u6253\u9020\u51fa\u771f\u6b63\u88ab\u7528\u6237\u62e5\u62b1\u3001\u4fe1\u4efb\u5e76\u4ece\u4e2d\u53d7\u76ca\u7684 AI \u4ea7\u54c1\u3002<\/p>\n<p>\u672c\u6587\u5c31\u662f\u6211\u5728\u6700\u8fd1\u4e24\u5e74\u5f00\u53d1 AI \u4ea7\u54c1\u7684\u4e00\u4e9b\u4f53\u609f\uff0c\u5e0c\u671b\u80fd\u591f\u7ed9 AI \u4ea7\u54c1\u7684\u8bbe\u8ba1\u548c\u5f00\u53d1\u5e26\u6765\u4e00\u4e9b\u542f\u53d1\u3002\u867d\u7136\u6211\u662f\u4e00\u4e2a\u5de5\u7a0b\u5e08\u89c6\u89d2\uff0c\u4f46\u662f\u6597\u80c6\u4eca\u5929\u5c31\u6765\u804a\u4e00\u804a AI \u4ea7\u54c1\u7684\u8bbe\u8ba1\u548c\u4f53\u9a8c\u95ee\u9898\u3002<\/p>\n<h2 id=\"\u7406\u89e3\u5f53\u524d-ai-\u7684\u9636\u6bb5\u80fd\u529b\u4e0e\u5c40\u9650\">\u7406\u89e3\u5f53\u524d AI \u7684\u9636\u6bb5\uff1a\u80fd\u529b\u4e0e\u5c40\u9650\n<\/h2><p>\u6bcb\u5eb8\u7f6e\u7591\uff0c\u73b0\u5728 AI \u5728\u201c\u529b\u5927\u7816\u98de\u201d\u7684\u80cc\u666f\u4e4b\u4e0b\uff0c\u5df2\u7ecf\u5728\u8bb8\u591a\u9886\u57df\u5c55\u73b0\u51fa\u4e86\u5f3a\u5927\u7684\u80fd\u529b\u3002\u4ece\u81ea\u7136\u8bed\u8a00\u5904\u7406\u5230\u8ba1\u7b97\u673a\u89c6\u89c9\uff0c\u4ece\u667a\u80fd\u63a8\u8350\u5230\u667a\u80fd\u5bf9\u8bdd\uff0cAI \u7684\u5e94\u7528\u573a\u666f\u8d8a\u6765\u8d8a\u5e7f\u6cdb\uff0c\u6280\u672f\u4e5f\u8d8a\u6765\u8d8a\u6210\u719f\u3002\u5728\u8fc7\u53bb\u7684\u4e24\u5e74\u4e2d\uff0c\u6211\u4eec\u89c1\u8bc1\u4e86\u6bcf\u9694\u51e0\u4e2a\u6708\u5230\u534a\u5e74\uff0cLLM \u5c31\u8fdb\u884c\u4e86\u4e00\u79cd\u5927\u8303\u56f4\u7684\u80fd\u529b\u63d0\u5347\u53d8\u9769\u3002\u7136\u800c\uff0cAI \u7684\u80fd\u529b\u548c\u5c40\u9650\u6027\u4e5f\u7ed9\u4ea7\u54c1\u8bbe\u8ba1\u5e26\u6765\u4e86\u8bb8\u591a\u6311\u6218\u3002\u8fd9\u4e9b\u5c40\u9650\u6027\u5e76\u975e\u662f\u65e0\u6cd5\u514b\u670d\u7684\uff0c\u6709\u4e9b\u4e5f\u4ec5\u4ec5\u5c40\u9650\u4e8e\u5f53\u524d\u7684\u6280\u672f\u6c34\u5e73\uff0c\u4f46\u662f\u6211\u4eec\u5fc5\u987b\u6e05\u695a\u5730\u8ba4\u8bc6\u5230\u8fd9\u4e9b\u5c40\u9650\u6027\uff0c\u624d\u80fd\u66f4\u597d\u5730\u8bbe\u8ba1\u548c\u5f00\u53d1 AI \u4ea7\u54c1\u3002<\/p>\n<p>\u8fd9\u4e9b\u95ee\u9898\u4f60\u53ef\u80fd\u5728\u5f88\u591a\u5730\u65b9\u770b\u5230\u8fc7\uff0c\u8ba9\u6211\u518d\u8d58\u8ff0\u4e00\u904d\uff1a<\/p>\n<ol>\n<li><strong>\u4e0a\u4e0b\u6587\u95ee\u9898<\/strong>\uff1a\u5927\u6a21\u578b\u5728\u5904\u7406\u957f\u6587\u672c\u6216\u590d\u6742\u5bf9\u8bdd\u65f6\uff0c\u53d7\u9650\u4e8e\u4e0a\u4e0b\u6587\u201c\u8bb0\u5fc6\u201d\u80fd\u529b\uff0c\u53ef\u80fd\u5bfc\u81f4\u7406\u89e3\u504f\u5dee\u548c\u4fe1\u606f\u9057\u6f0f\u3002\u4f8b\u5982\uff0c\u5728\u957f\u7bc7\u6587\u6863\u603b\u7ed3\u6216\u591a\u8f6e\u5bf9\u8bdd\u4e2d\u96be\u4ee5\u4fdd\u6301\u4fe1\u606f\u8fde\u8d2f\u3002\u6269\u5c55\u4e0a\u4e0b\u6587\u7a97\u53e3\u5f53\u7136\u662f\u4e00\u79cd\u89e3\u51b3\u65b9\u6848\uff0c\u4f46\u5373\u4fbf\u662f\u5927\u4e0a\u4e0b\u6587\u7a97\u53e3\u7684 Gemini\uff0c\u4e5f\u4f1a\u51fa\u73b0\u6ce8\u610f\u529b\u4e0d\u96c6\u4e2d\u7684\u95ee\u9898\uff0c\u6700\u7ec8\u5f71\u54cd\u5230\u6a21\u578b\u7684\u6027\u80fd\u548c\u7ed3\u679c\u3002<\/li>\n<li><strong>\u5e7b\u89c9\u95ee\u9898<\/strong>\uff1aAI \u53ef\u80fd\u5728\u7f3a\u4e4f\u4e8b\u5b9e\u4f9d\u636e\u7684\u60c5\u51b5\u4e0b\u751f\u6210\u770b\u4f3c\u5408\u7406\u4f46\u865a\u5047\u7684\u4fe1\u606f\uff0c\u4e25\u91cd\u5f71\u54cd\u7528\u6237\u4fe1\u4efb\uff0c\u5c24\u5176\u5728\u9700\u8981\u9ad8\u51c6\u786e\u6027\u7684\u573a\u666f\u4e2d\u3002\u5728\u7edd\u5927\u591a\u6570\u7684 B \u7aef\u573a\u666f\u548c\u90e8\u5206 C \u7aef\u573a\u666f\u4e2d\uff0c\u6211\u4eec\u90fd\u9700\u8981\u786e\u4fdd\u56de\u7b54\u7684\u51c6\u786e\u6027\u3002\u4e4b\u524d\u4e5f\u6709<a class=\"link\" href=\"https:\/\/news.qq.com\/rain\/a\/20240223A012Z100\" target=\"_blank\" rel=\"noopener\"\n>\u52a0\u62ff\u5927\u822a\u7a7a\u7684\u6848\u4f8b<\/a>\uff0c\u5bfc\u81f4\u516c\u53f8\u7684\u4fe1\u8a89\u53d7\u635f\u3002<\/li>\n<li><strong>\u7f3a\u4e4f\u5e38\u8bc6\u4e0e\u60c5\u611f\u7406\u89e3<\/strong>\uff1a AI \u5728\u5904\u7406\u9700\u8981\u5e38\u8bc6\u5224\u65ad\u548c\u60c5\u611f\u7406\u89e3\u7684\u573a\u666f\u4e2d\u8868\u73b0\u4e0d\u8db3\uff0c\u5bfc\u81f4\u4ea4\u4e92\u751f\u786c\uff0c\u751a\u81f3\u4ea7\u751f\u8bef\u89e3\u3002<\/li>\n<\/ol>\n<p>\u8fd9\u4e9b\u95ee\u9898\u5e76\u975e\u65e0\u6cd5\u89e3\u51b3\uff0c\u4f46\u662f\u6211\u4eec\u5fc5\u987b\u6e05\u695a\u5730\u8ba4\u8bc6\u5230\u8fd9\u4e9b\u95ee\u9898\uff0c\u624d\u80fd\u66f4\u597d\u5730\u8bbe\u8ba1\u548c\u5f00\u53d1 AI \u4ea7\u54c1\u3002\u5728 AI \u4ea7\u54c1\u8bbe\u8ba1\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u5145\u5206\u8003\u8651\u8fd9\u4e9b\u95ee\u9898\uff0c\u4ece\u800c\u66f4\u597d\u5730\u6ee1\u8db3\u7528\u6237\u7684\u9700\u6c42\u548c\u4f53\u9a8c\u3002\u800c\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u6211\u8ba4\u4e3a\u9488\u5bf9\u4eba\u673a\u56de\u73af(Human in the loop, HITL)\u7684\u8bbe\u8ba1\u601d\u60f3\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u901a\u8fc7\u5b8c\u5584\u8fd9\u4e2a\u8bbe\u8ba1\u601d\u60f3\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u597d\u5730\u89e3\u51b3\u4e0a\u8ff0\u95ee\u9898\uff0c\u63d0\u9ad8 AI \u4ea7\u54c1\u7684\u8d28\u91cf\u548c\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<h2 id=\"\u4ee5\u4eba\u4e3a\u672c\u4ea7\u54c1\u7684\u8bbe\u8ba1\u7075\u9b42\">\u4ee5\u4eba\u4e3a\u672c\uff1a\u4ea7\u54c1\u7684\u8bbe\u8ba1\u7075\u9b42\n<\/h2><p>\u4ee5\u4eba\u4e3a\u672c\uff0c\u662f\u4ea7\u54c1\u8bbe\u8ba1\u7684\u7075\u9b42\u6240\u5728\uff0c\u5bf9\u4e8e AI \u4ea7\u54c1\u800c\u8a00\u66f4\u662f\u5982\u6b64\u3002\u5bf9\u8fd9\u79cd\u65b9\u5f0f\u800c\u8a00\uff0c\u4e00\u822c\u4f1a\u4ee5\u4e0b\u9762\u7684\u65b9\u5f0f\u4e3a\u5faa\u73af\u6765\u8fdb\u884c\uff1a<\/p>"},{"title":"\u4f7f\u7528 Go \u5f00\u53d1 AI Agent\u7684\u9009\u62e9\uff1aGenkit for Go","link":"https:\/\/www.4async.com\/2024\/11\/building-ai-agent-with-genkit-for-go\/","pubDate":"Thu, 14 Nov 2024 11:28:00 +0000","guid":"https:\/\/www.4async.com\/2024\/11\/building-ai-agent-with-genkit-for-go\/","description":"<img src=\"https:\/\/www.4async.com\/2024\/11\/building-ai-agent-with-genkit-for-go\/cover.png\" alt=\"Featured image of post \u4f7f\u7528 Go \u5f00\u53d1 AI Agent\u7684\u9009\u62e9\uff1aGenkit for Go\" \/><h2 id=\"\u4ec0\u4e48\u662f-genkit\">\u4ec0\u4e48\u662f Genkit\n<\/h2><p><a class=\"link\" href=\"https:\/\/github.com\/firebase\/genkit\" target=\"_blank\" rel=\"noopener\"\n>Genkit<\/a> \u662f\u4e00\u4e2a Google Firebase \u56e2\u961f\u5f00\u53d1\u7684 AI Agent \u5f00\u53d1\u6846\u67b6\uff0c\u7528\u4e8e\u6784\u5efa\u73b0\u4ee3\u3001\u9ad8\u6548\u7684 AI \u5e94\u7528\u3002\u5b83\u76ee\u524d\u5305\u542b\u4e00\u4e2a <a class=\"link\" href=\"https:\/\/firebase.google.com\/docs\/genkit?hl=zh-cn\" target=\"_blank\" rel=\"noopener\"\n>Node.js \u7684\u5b9e\u73b0<\/a> \u548c\u4e00\u4e2a <a class=\"link\" href=\"https:\/\/firebase.google.com\/docs\/genkit-go\/get-started-go\" target=\"_blank\" rel=\"noopener\"\n>Go \u8bed\u8a00\u7684\u5b9e\u73b0<\/a>\u3002\u4e4b\u6240\u4ee5\u6ce8\u610f\u5230\u8fd9\u4e2a\u6846\u67b6\u662f\u56e0\u4e3a Go \u56e2\u961f\u5728\u4ed6\u4eec\u7684<a class=\"link\" href=\"https:\/\/go.dev\/blog\/15years\" target=\"_blank\" rel=\"noopener\"\n>\u5341\u4e94\u5468\u5e74\u535a\u5ba2<\/a>\u4e2d\u63d0\u5230\u4e86\u5b83\u3002Go \u56e2\u961f\u5728\u535a\u5ba2\u4e2d\u63d0\u5230\uff0c\u4ed6\u4eec\u6b63\u5728\u52aa\u529b\u4f7f Go \u6210\u4e3a\u6784\u5efa\u751f\u4ea7 AI \u7cfb\u7edf\u7684\u4f18\u79c0\u8bed\u8a00\uff0c\u5e76\u4e14\u4ed6\u4eec\u6b63\u5728\u4e3a\u6d41\u884c\u7684 Go \u8bed\u8a00\u6846\u67b6\u63d0\u4f9b\u652f\u6301\uff0c\u5305\u62ec <a class=\"link\" href=\"https:\/\/github.com\/tmc\/langchaingo\" target=\"_blank\" rel=\"noopener\"\n>LangChainGo<\/a> \u548c <a class=\"link\" href=\"https:\/\/developers.googleblog.com\/en\/introducing-genkit-for-go-build-scalable-ai-powered-apps-in-go\/\" target=\"_blank\" rel=\"noopener\"\n>Genkit<\/a>\u3002\u5982\u679c\u4f60\u4e86\u89e3\u8fc7 AI \u5f00\u53d1\uff0c\u90a3\u4e48 <a class=\"link\" href=\"https:\/\/www.langchain.com\/\" target=\"_blank\" rel=\"noopener\"\n>LangChain<\/a> \u4e00\u5b9a\u5e76\u4e0d\u964c\u751f\u3002LangChainGo \u5c31\u662f LangChain \u7684 Go \u8bed\u8a00\u5b9e\u73b0\u3002\u4f46\u662f\u5bf9\u5e94\u7684\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u4e00\u4e2a\u5355\u72ec\u7684 AI Agent \u5f00\u53d1\u6846\u67b6\uff0c\u5e2e\u52a9\u6211\u4eec\u7ec4\u7ec7 AI Agent \u7684\u5f00\u53d1\u3002LangChain \u7684\u751f\u6001\u4f4d\u4e2d\uff0c\u5bf9\u5e94\u7684\u662f <a class=\"link\" href=\"https:\/\/www.langchain.com\/langgraph\" target=\"_blank\" rel=\"noopener\"\n>LangGraph<\/a>\uff0c\u5728 Go \u8bed\u8a00\u7684\u751f\u6001\u4f4d\u4e2d\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9 Genkit \u6216\u8005 <a class=\"link\" href=\"https:\/\/github.com\/tmc\/langgraphgo\" target=\"_blank\" rel=\"noopener\"\n>LangGraphGo<\/a>\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u76ee\u524d Genkit \u4ecd\u65e7\u662f\u5728 Alpha \u7684\u72b6\u6001\uff0c\u6240\u4ee5\uff0c<strong>\u5982\u679c\u4f60\u5e0c\u671b\u5c06 Genkit \u7528\u4e8e\u751f\u4ea7\u73af\u5883\uff0c\u5728 2024 \u5e74\u8fd9\u4e2a\u65f6\u95f4\u70b9\u8bf7\u6ce8\u610f\u672a\u6765\u53ef\u80fd\u7684 API \u53d8\u52a8\u3002<\/strong> \u76ee\u524d Genkit \u5b98\u65b9\u652f\u6301\u7684\u6a21\u578b\u529f\u80fd\u4ecd\u65e7\u662f\u4ee5 Google \u5bb6\u7684\u4ea7\u54c1\u4e3a\u4e3b\uff0c\u5982\u679c\u4f60\u9700\u8981\u4f7f\u7528\u5176\u4ed6 AI \u6a21\u578b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u6682\u65f6\u5148\u4f7f\u7528\u7b2c\u4e09\u65b9 plugin\uff08\u6bd4\u5982 OpenAI\uff09\u3002<\/p>"},{"title":"RAG \u6280\u672f\u5728\u5b9e\u9645\u5de5\u7a0b\u4e2d\u7684\u5e94\u7528\uff1aOpenAI \u7684\u6700\u4f73\u5b9e\u8df5\u5206\u4eab","link":"https:\/\/www.4async.com\/2024\/06\/openai-survey-of-techniques-for-maximizing-llm-performance\/","pubDate":"Mon, 03 Jun 2024 11:15:00 +0000","guid":"https:\/\/www.4async.com\/2024\/06\/openai-survey-of-techniques-for-maximizing-llm-performance\/","description":"<img src=\"https:\/\/www.4async.com\/2024\/06\/openai-survey-of-techniques-for-maximizing-llm-performance\/cover.png\" alt=\"Featured image of post RAG \u6280\u672f\u5728\u5b9e\u9645\u5de5\u7a0b\u4e2d\u7684\u5e94\u7528\uff1aOpenAI \u7684\u6700\u4f73\u5b9e\u8df5\u5206\u4eab\" \/><p>\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff08Retrieval Augmented Generation\uff0c\u7b80\u79f0RAG\uff09\u6280\u672f\u6b63\u9010\u6e10\u6210\u4e3a\u63d0\u5347\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08LLM\uff09\u6027\u80fd\u7684\u5173\u952e\u3002OpenAI \u7684 John Allard \u548c Colin Jarvis \u5728<a class=\"link\" href=\"https:\/\/www.youtube.com\/watch?v=ahnGLM-RC1Y\" target=\"_blank\" rel=\"noopener\"\n>\u4e00\u573a\u5206\u4eab<\/a>\u4e2d\uff0c\u4ee5\u5b9e\u9645\u6848\u4f8b\u4e3a\u57fa\u7840\uff0c\u6df1\u5165\u6d45\u51fa\u5730\u8bb2\u89e3\u4e86\u5982\u4f55\u5c06 RAG \u6280\u672f\u5e94\u7528\u4e8e\u5b9e\u9645\u5de5\u7a0b\u95ee\u9898\uff0c\u5e76\u5206\u4eab\u4e86\u4ed6\u4eec\u7684\u6700\u4f73\u5b9e\u8df5\u7ecf\u9a8c\u3002\u8fd9\u4e9b\u5185\u5bb9\u5bf9\u4e8e RAG \u6280\u672f\u7684\u5e94\u7528\u8005\u6765\u8bf4\uff0c\u65e0\u7591\u662f\u975e\u5e38\u6709\u4ef7\u503c\u7684\u3002\u4e8b\u5b9e\u4e0a\uff0cOpenAI \u5f00\u653e\u4e86\u5f88\u591a\u7684\u4ed6\u4eec\u7684\u6700\u4f73\u5b9e\u8df5\u5185\u5bb9\uff0c\u5305\u62ec\u4e0d\u9650\u4e8e Prompt Engineering\u3001Data Augmentation\u3001Fine-tuning\u3001Inference Optimization \u7b49\u7b49\u3002\u6709\u7a7a\u9664\u4e86\u591a\u770b\u4e00\u4e0b\u76f8\u5173\u8bba\u6587\uff0cOpenAI \u7684 Github \u548c Youtube \u9891\u9053\u90fd\u503c\u5f97\u770b\u4e00\u4e0b\u3002\u6bd4\u5982\u8bf4\u8fd9\u6b21\u5206\u4eab\u5c31\u662f\u6765\u6e90\u4e8e OpenAI \u7684 Youtube \u9891\u9053\u3002<\/p>\n<h2 id=\"\u4f18\u5316-llm-\u6027\u80fd\u7684\u6311\u6218\">\u4f18\u5316 LLM \u6027\u80fd\u7684\u6311\u6218\n<\/h2><p>\u4f18\u5316 LLM \u6027\u80fd\u5e76\u975e\u6613\u4e8b\uff0c\u54ea\u6015\u4e01\u70b9\u7684\u533a\u522b\u90fd\u53ef\u80fd\u5bfc\u81f4\u7ed3\u679c\u4e0a\u51fa\u73b0\u5f88\u5927\u7684\u5dee\u5f02\u3002\u76ee\u524d\u4f18\u5316\u6027\u80fd\u4e3b\u8981\u5b58\u5728\u4ee5\u4e0b\u6311\u6218\uff1a<\/p>\n<ul>\n<li><strong>\u96be\u4ee5\u786e\u5b9a\u95ee\u9898\u6839\u6e90<\/strong>\uff1a LLM \u7684\u8f93\u51fa\u7ed3\u679c\u53d7\u591a\u79cd\u56e0\u7d20\u5f71\u54cd\uff0c\u5982\u63d0\u793a\u5de5\u7a0b\u3001\u8bad\u7ec3\u6570\u636e\u3001\u6a21\u578b\u67b6\u6784\u7b49\u3002\u5f53\u6a21\u578b\u6027\u80fd\u4e0d\u4f73\u65f6\uff0c\u96be\u4ee5\u4ece\u8fd9\u4e9b\u590d\u6742\u7684\u4ea4\u4e92\u4e2d\u5206\u79bb\u51fa\u5bfc\u81f4\u95ee\u9898\u7684\u5177\u4f53\u539f\u56e0\u3002<\/li>\n<li><strong>\u96be\u4ee5\u8861\u91cf\u6027\u80fd<\/strong>\uff1a \u5bf9\u4e8e\u8bb8\u591a LLM \u5e94\u7528\uff0c\u4f8b\u5982\u6587\u672c\u6458\u8981\u3001\u95ee\u7b54\u7cfb\u7edf\u7b49\uff0c\u96be\u4ee5\u627e\u5230\u4e00\u4e2a\u5ba2\u89c2\u7684\u3001\u53ef\u91cf\u5316\u7684\u6307\u6807\u6765\u51c6\u786e\u8bc4\u4f30\u6a21\u578b\u7684\u6027\u80fd\u3002<\/li>\n<li><strong>\u96be\u4ee5\u9009\u62e9\u4f18\u5316\u65b9\u6cd5<\/strong>\uff1a \u5373\u4f7f\u786e\u5b9a\u4e86\u95ee\u9898\uff0c\u4e5f\u96be\u4ee5\u9009\u62e9\u6700\u5408\u9002\u7684\u4f18\u5316\u65b9\u6cd5\u3002\u5f00\u53d1\u8005\u9700\u8981\u6839\u636e\u5177\u4f53\u95ee\u9898\u9009\u62e9\u5408\u9002\u7684\u6280\u672f\uff0c\u4f8b\u5982\u63d0\u793a\u5de5\u7a0b\u3001\u5fae\u8c03\u3001RAG \u7b49\u3002<\/li>\n<\/ul>\n<h2 id=\"openai-\u7684\u4f18\u5316\u6846\u67b6\">OpenAI \u7684\u4f18\u5316\u6846\u67b6\n<\/h2><p>\u4e3a\u4e86\u89e3\u51b3\u4e0a\u8ff0\u6311\u6218\uff0cOpenAI \u63d0\u51fa\u4e86\u4e00\u4e2a\u4e8c\u7ef4\u4f18\u5316\u6846\u67b6\uff0c\u5c06\u4f18\u5316\u65b9\u5411\u5206\u4e3a__\u5185\u5bb9\u4f18\u5316__\u548c__LLM\u4f18\u5316__\u4e24\u4e2a\u90e8\u5206\u3002<\/p>\n<h3 id=\"\u5185\u5bb9\u4f18\u5316\">\u5185\u5bb9\u4f18\u5316\n<\/h3><p>\u5185\u5bb9\u4f18\u5316\u6307\u7684\u662f\u4f18\u5316\u6a21\u578b\u53ef\u8bbf\u95ee\u7684\u77e5\u8bc6\u5185\u5bb9\u3002\u5982\u679c\u6a21\u578b\u7f3a\u4e4f\u5fc5\u8981\u7684\u77e5\u8bc6\u6216\u4fe1\u606f\u8d28\u91cf\u8f83\u5dee\uff0c\u90a3\u4e48\u5373\u4f7f\u6a21\u578b\u672c\u8eab\u7684\u80fd\u529b\u5f88\u5f3a\uff0c\u4e5f\u96be\u4ee5\u7ed9\u51fa\u4ee4\u4eba\u6ee1\u610f\u7684\u7b54\u6848\u3002<\/p>\n<p>\u4e3a\u4e86\u8865\u5168\u8fd9\u90e8\u5206\u7684\u77e5\u8bc6\u5185\u5bb9\uff0c\u53ef\u4ee5\u91c7\u7528\u4ee5\u4e0b\u65b9\u6cd5\u8fdb\u884c\uff1a<\/p>\n<ul>\n<li><strong>RAG<\/strong>\uff1a \u5c06\u5916\u90e8\u77e5\u8bc6\u5e93\u4e0e LLM \u96c6\u6210\uff0c\u5141\u8bb8\u6a21\u578b\u8bbf\u95ee\u66f4\u5e7f\u6cdb\u3001\u66f4\u4e13\u4e1a\u7684\u77e5\u8bc6\u3002<\/li>\n<li><strong>\u6570\u636e\u589e\u5f3a<\/strong>\uff1a \u901a\u8fc7\u5bf9\u73b0\u6709\u6570\u636e\u8fdb\u884c\u6269\u5c55\u6216\u8f6c\u6362\uff0c\u589e\u52a0\u8bad\u7ec3\u6570\u636e\u7684\u6570\u91cf\u548c\u591a\u6837\u6027\u3002<\/li>\n<li><strong>\u6570\u636e\u6e05\u6d17<\/strong>\uff1a \u8bc6\u522b\u548c\u7ea0\u6b63\u8bad\u7ec3\u6570\u636e\u4e2d\u7684\u9519\u8bef\u6216\u566a\u58f0\uff0c\u63d0\u9ad8\u6570\u636e\u8d28\u91cf\u3002<\/li>\n<\/ul>\n<h3 id=\"llm-\u4f18\u5316\">LLM \u4f18\u5316\n<\/h3><p>\u901a\u8fc7\u4f18\u5316\u6a21\u578b\u672c\u8eab\u63d0\u5347\u6548\u679c\u3002\u5982\u679c\u6a21\u578b\u672c\u8eab\u5b58\u5728\u7f3a\u9677\uff0c\u4f8b\u5982\u5bb9\u6613\u4ea7\u751f\u5e7b\u89c9\u6216\u96be\u4ee5\u7406\u89e3\u590d\u6742\u6307\u4ee4\uff0c\u90a3\u4e48\u5373\u4f7f\u6709\u5145\u8db3\u7684\u77e5\u8bc6\uff0c\u4e5f\u96be\u4ee5\u7ed9\u51fa\u5408\u7406\u7684\u7b54\u6848\u3002<\/p>\n<p>\u5728\u8fd9\u4e2a\u4f18\u5316\u65b9\u6848\u4e2d\uff0c\u53ef\u4ee5\u91c7\u7528\u4e0b\u9762\u7684\u65b9\u5f0f\u8fdb\u884c\uff1a<\/p>\n<ul>\n<li><strong>\u63d0\u793a\u5de5\u7a0b<\/strong>\uff1a \u901a\u8fc7\u8bbe\u8ba1\u66f4\u6e05\u6670\u3001\u66f4\u660e\u786e\u7684\u63d0\u793a\uff0c\u5f15\u5bfc\u6a21\u578b\u751f\u6210\u7b26\u5408\u9884\u671f\u7684\u8f93\u51fa\u3002<\/li>\n<li><strong>\u5fae\u8c03<\/strong>\uff1a \u4f7f\u7528\u7279\u5b9a\u4efb\u52a1\u7684\u6570\u636e\u96c6\u5bf9\u9884\u8bad\u7ec3\u6a21\u578b\u8fdb\u884c\u8fdb\u4e00\u6b65\u8bad\u7ec3\uff0c\u4f7f\u6a21\u578b\u66f4\u9002\u5e94\u7279\u5b9a\u4efb\u52a1\u3002<\/li>\n<li><strong>\u6a21\u578b\u67b6\u6784\u4f18\u5316<\/strong>\uff1a \u8c03\u6574\u6a21\u578b\u7684\u67b6\u6784\u6216\u53c2\u6570\uff0c\u63d0\u9ad8\u6a21\u578b\u7684\u5b66\u4e60\u80fd\u529b\u548c\u6cdb\u5316\u80fd\u529b\u3002<\/li>\n<\/ul>\n<h3 id=\"openai-\u7684\u5efa\u8bae\">OpenAI \u7684\u5efa\u8bae\n<\/h3><p>\u5728\u8fd9\u4e2a\u6846\u67b6\u4e0b\uff0cOpenAI \u5efa\u8bae\u5f00\u53d1\u8005\u91c7\u7528\u4ee5\u4e0b\u6d41\u7a0b\u8fdb\u884c\u4f18\u5316\uff1a<\/p>"},{"title":"\u4ece\u96f6\u5b66\u4e60 Hypothetical Document Embeddings (HyDE) - 2","link":"https:\/\/www.4async.com\/2024\/04\/learn-hyde-from-scratch-2\/","pubDate":"Wed, 10 Apr 2024 09:15:00 +0000","guid":"https:\/\/www.4async.com\/2024\/04\/learn-hyde-from-scratch-2\/","description":"<img src=\"https:\/\/www.4async.com\/2024\/04\/learn-hyde-from-scratch-2\/cover.png\" alt=\"Featured image of post \u4ece\u96f6\u5b66\u4e60 Hypothetical Document Embeddings (HyDE) - 2\" \/><p>\u5728\u5f00\u59cb\u770b\u8fd9\u7bc7\u6587\u7ae0\u4e4b\u524d\uff0c\u63a8\u8350\u4f60\u9605\u8bfb\u524d\u4e00\u7bc7<a class=\"link\" href=\"https:\/\/www.4async.com\/2024\/04\/learn-hyde-from-scratch-1\/\" title=\"\u6982\u5ff5\u4ecb\u7ecd\u6587\u7ae0\"\ntarget=\"_blank\" rel=\"noopener\"\n>\u6982\u5ff5\u4ecb\u7ecd\u6587\u7ae0<\/a>\u3002\u8fd9\u7bc7\u6587\u7ae0\u4e4b\u5185\u4e0d\u4f1a\u518d\u989d\u5916\u4ecb\u7ecd\u6982\u5ff5\u4e0a\u7684\u5185\u5bb9\uff0c\u4ec5\u4ec5\u4ece\u5b9e\u8df5\u89d2\u5ea6\u6f14\u793a\u5982\u4f55\u662f\u7528 HyDE \u548c RAG \u7ed3\u5408\u3002\u6b63\u5982\u540c\u524d\u6587\u63d0\u5230\u7684\u90a3\u6837\uff0c\u6211\u4eec\u4f1a\u662f\u7528 LangChain \u6784\u5efa\u8fd9\u4e2a\u6f14\u793a Demo\u3002\u5f53\u7136\uff0c\u5982\u679c\u4f60\u719f\u6089 LlamaIndex \u6216\u8005\u5176\u4ed6\u6846\u67b6\uff0c\u5176\u5b9e\u4e3b\u8981\u6d41\u7a0b\u5927\u81f4\u5dee\u4e0d\u591a\uff0c\u53ea\u4e0d\u8fc7\u662f\u7528\u7684 API \u548c\u5e93\u6709\u4e00\u4e9b\u533a\u522b\u3002\u8fd9\u4e9b\u5c31\u4e0d\u518d\u8d58\u8ff0\u3002<\/p>\n<h2 id=\"\u95ee\u9898\u80cc\u666f\">\u95ee\u9898\u80cc\u666f\n<\/h2><p>\u8ba9\u6211\u4eec\u5047\u8bbe\u4f60\u5728\u4e3a\u9ea6\u5f53\u52b3\u5236\u4f5c\u4e00\u4e2a\u95ee\u7b54\u7cfb\u7edf\u3002\u8fd9\u4e2a\u95ee\u7b54\u7cfb\u7edf\u7684\u76ee\u7684\u662f\u5e2e\u52a9\u7528\u6237\u89e3\u51b3\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\uff0c\u6bd4\u5982\uff1a\u9ea6\u5f53\u52b3\u7684\u8425\u4e1a\u65f6\u95f4\uff0c\u9ea6\u5f53\u52b3\u7684\u83dc\u5355\uff0c\u9ea6\u5f53\u52b3\u7684\u4f18\u60e0\u6d3b\u52a8\u7b49\u7b49\u3002\u8fd9\u4e9b\u95ee\u9898\u7684\u7b54\u6848\u901a\u5e38\u662f\u53ef\u4ee5\u5728\u9ea6\u5f53\u52b3\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0a\u627e\u5230\u7684\uff0c\u4f46\u662f\u7528\u6237\u53ef\u80fd\u5e76\u4e0d\u77e5\u9053\u8fd9\u4e9b\u4fe1\u606f\uff0c\u6216\u8005\u4ed6\u4eec\u53ef\u80fd\u4f1a\u7528\u81ea\u5df1\u7684\u65b9\u5f0f\u63d0\u51fa\u95ee\u9898\u3002\u8fd9\u65f6\u5019\uff0c\u6211\u4eec\u5c31\u9700\u8981\u4e00\u4e2a RAG \u6a21\u578b\u6765\u5e2e\u52a9\u6211\u4eec\u56de\u7b54\u8fd9\u4e9b\u95ee\u9898\u3002\u4f46\u662f\u9ea6\u5f53\u52b3\u5b9e\u9645\u4e0a\u6709\u975e\u5e38\u591a\u7684\u5546\u54c1\uff0c\u90a3\u4e48\u5b83\u7684\u77e5\u8bc6\u5e93\u53ef\u80fd\u4f1a\u975e\u5e38\u5927\uff0c\u800c\u4e14\u7528\u6237\u63d0\u51fa\u7684\u95ee\u9898\u53ef\u80fd\u5e76\u4e0d\u5728\u77e5\u8bc6\u5e93\u4e2d\u3002\u8fd9\u65f6\u5019 HyDE \u5c31\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5904\u7406\u8fd9\u4e9b\u95ee\u9898\u3002<\/p>\n<h2 id=\"\u51c6\u5907\u5de5\u4f5c\">\u51c6\u5907\u5de5\u4f5c\n<\/h2><p>\u6211\u4eec\u4f1a\u662f\u7528\u4e00\u4e9b\u57fa\u672c\u7684 Python \u76f8\u5173\u5de5\u5177(<a class=\"link\" href=\"https:\/\/pdm.fming.dev\/latest\/\" title=\"pdm\"\ntarget=\"_blank\" rel=\"noopener\"\n>pdm<\/a> \u7b49\u7b49)\u3001<a class=\"link\" href=\"https:\/\/ollama.com\/\" title=\"Ollama\"\ntarget=\"_blank\" rel=\"noopener\"\n>Ollama<\/a>\u548c<a class=\"link\" href=\"https:\/\/www.trychroma.com\/\" title=\"chroma\"\ntarget=\"_blank\" rel=\"noopener\"\n>chroma<\/a>\u3002\u5173\u4e8e Ollama \u7684\u4ecb\u7ecd\uff0c\u53ef\u4ee5\u67e5\u770b<a class=\"link\" href=\"https:\/\/www.4async.com\/2024\/02\/deploy-local-llm-using-ollama\/\" title=\"\u6211\u7684\u4e4b\u524d\u7684\u6587\u7ae0\"\ntarget=\"_blank\" rel=\"noopener\"\n>\u6211\u7684\u4e4b\u524d\u7684\u6587\u7ae0<\/a>\u3002\u51fa\u4e8e\u6210\u672c\u8003\u8651\uff0c\u8fd9\u91cc\u4f7f\u7528\u4e86\u5f00\u6e90\u7684\u672c\u5730\u6a21\u578b\u5b9e\u73b0\uff0c\u8bf7\u786e\u4fdd\u4f60\u7684 Ollama \u662f\u5728\u8fd0\u884c\u7684\u72b6\u6001\u3002\u5f53\u7136\uff0c\u5982\u679c\u4f60\u662f\u7528 <a class=\"link\" href=\"https:\/\/platform.openai.com\/docs\/models\/gpt-4-turbo-and-gpt-4\" title=\"GPT-4 Turbo\"\ntarget=\"_blank\" rel=\"noopener\"\n>GPT-4 Turbo<\/a>\uff08\u4eca\u5929\u51cc\u6668\u521a\u521a\u53d1\u5e03\u4e86\u65b0\u7248\u672c\uff09\uff0c\u6548\u679c\u8981\u8fdc\u6bd4\u5f00\u6e90\u6a21\u578b\u597d\u5f88\u591a\u3002<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-shell\" data-lang=\"shell\"><span style=\"display:flex;\"><span>mkdir hydemo <span style=\"color:#f92672\">&amp;&amp;<\/span> cd hydemo\n<\/span><\/span><span style=\"display:flex;\"><span>pdm init\n<\/span><\/span><span style=\"display:flex;\"><span>pdm add langchain chromadb beautifulsoup4\n<\/span><\/span><span style=\"display:flex;\"><span>source .venv\/bin\/activate\n<\/span><\/span><\/code><\/pre><\/div><blockquote>\n<p>\u8bf7\u6ce8\u610f\uff0c\u5728\u672c\u6587\u7f16\u5199\u65f6\uff0c\u4f7f\u7528\u7684 LangChain \u7684\u7248\u672c\u4e3a 0.1.14\uff0c\u5982\u679c\u4f60\u7684\u7248\u672c\u8f83\u4f4e\u6216\u8005\u8fc7\u9ad8\uff0c\u53ef\u80fd\u5b58\u5728\u90e8\u5206 API \u51fa\u5165\uff0c\u8bf7\u6839\u636e\u5177\u4f53\u60c5\u51b5\u8c03\u6574\u5f15\u7528\u7684\u6a21\u5757\u548c\u5bf9\u5e94\u7684 API\u3002<\/p><\/blockquote>\n<h2 id=\"\u529f\u80fd\u5b9e\u73b0\">\u529f\u80fd\u5b9e\u73b0\n<\/h2><h3 id=\"\u5b9e\u73b0\u751f\u6210\u6a21\u62df\u6587\u6863\">\u5b9e\u73b0\u751f\u6210\u6a21\u62df\u6587\u6863\n<\/h3><div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-python\" data-lang=\"python\"><span style=\"display:flex;\"><span><span style=\"color:#f92672\">from<\/span> langchain.chains.hyde.base <span style=\"color:#f92672\">import<\/span> HypotheticalDocumentEmbedder\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#f92672\">from<\/span> langchain.chains.llm <span style=\"color:#f92672\">import<\/span> LLMChain\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#f92672\">from<\/span> langchain.embeddings.ollama <span style=\"color:#f92672\">import<\/span> OllamaEmbeddings\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#f92672\">from<\/span> langchain.globals <span style=\"color:#f92672\">import<\/span> set_debug\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#f92672\">from<\/span> langchain.llms.ollama <span style=\"color:#f92672\">import<\/span> Ollama\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#f92672\">from<\/span> langchain.vectorstores.chroma <span style=\"color:#f92672\">import<\/span> Chroma\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">def<\/span> <span style=\"color:#a6e22e\">main<\/span>():\n<\/span><\/span><span style=\"display:flex;\"><span> set_debug(<span style=\"color:#66d9ef\">True<\/span>) <span style=\"color:#75715e\"># \u8bbe\u7f6e langchain \u7684\u8c03\u8bd5\u6a21\u5f0f\uff0c\u540e\u9762\u6211\u4eec\u4f1a\u770b\u5230\u5177\u4f53\u7684\u6548\u679c<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> llm <span style=\"color:#f92672\">=<\/span> Ollama(model<span style=\"color:#f92672\">=<\/span><span style=\"color:#e6db74\">&#34;qwen:7b&#34;<\/span>) <span style=\"color:#75715e\"># \u4f7f\u7528\u901a\u4e49\u5343\u95ee 7b \u6a21\u578b<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> olemb <span style=\"color:#f92672\">=<\/span> OllamaEmbeddings(\n<\/span><\/span><span style=\"display:flex;\"><span> model<span style=\"color:#f92672\">=<\/span><span style=\"color:#e6db74\">&#34;nomic-embed-text&#34;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> ) <span style=\"color:#75715e\"># \u5d4c\u5165\u6a21\u578b\u6211\u4eec\u662f\u4f7f\u7528\u7684 nomic-embed-text<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> embeddings <span style=\"color:#f92672\">=<\/span> HypotheticalDocumentEmbedder<span style=\"color:#f92672\">.<\/span>from_llm(\n<\/span><\/span><span style=\"display:flex;\"><span> llm,\n<\/span><\/span><span style=\"display:flex;\"><span> base_embeddings<span style=\"color:#f92672\">=<\/span>olemb,\n<\/span><\/span><span style=\"display:flex;\"><span> prompt_key<span style=\"color:#f92672\">=<\/span><span style=\"color:#e6db74\">&#34;web_search&#34;<\/span>, <span style=\"color:#75715e\"># \u52a0\u8f7d\u9884\u7f6e\u7684 Web Search Prompt<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> )\n<\/span><\/span><span style=\"display:flex;\"><span> print(embeddings<span style=\"color:#f92672\">.<\/span>llm_chain<span style=\"color:#f92672\">.<\/span>prompt)\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">if<\/span> __name__ <span style=\"color:#f92672\">==<\/span> <span style=\"color:#e6db74\">&#34;__main__&#34;<\/span>:\n<\/span><\/span><span style=\"display:flex;\"><span> main()\n<\/span><\/span><\/code><\/pre><\/div><p>\u8ba9\u6211\u4eec\u5148\u6267\u884c\u4e00\u4e0b\uff0c\u770b\u4e00\u4e0b Prompt \u4f1a\u662f\u4ec0\u4e48\u6837\u5b50\u7684\uff1a<\/p>"},{"title":"\u4ece\u96f6\u5b66\u4e60 Hypothetical Document Embeddings (HyDE) - 1","link":"https:\/\/www.4async.com\/2024\/04\/learn-hyde-from-scratch-1\/","pubDate":"Tue, 09 Apr 2024 14:15:00 +0000","guid":"https:\/\/www.4async.com\/2024\/04\/learn-hyde-from-scratch-1\/","description":"<img src=\"https:\/\/www.4async.com\/2024\/04\/learn-hyde-from-scratch-1\/cover.png\" alt=\"Featured image of post \u4ece\u96f6\u5b66\u4e60 Hypothetical Document Embeddings (HyDE) - 1\" \/><p>\u6700\u8fd1\u770b\u5230\u4e86\u4e00\u7bc7\u65b0\u7684\u8bba\u6587\uff0c\u5173\u4e8e\u8bc4\u4f30 RAG \u4e2d\u7684\u5404\u79cd\u6280\u672f\u7684\u8bc4\u4f30\u3002\u8fd9\u7bc7<a class=\"link\" href=\"https:\/\/arxiv.org\/pdf\/2404.01037.pdf\" target=\"_blank\" rel=\"noopener\"\n>\u300aARAGOG: Advanced RAG Output Grading\u300b<\/a>\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5bf9\u6bd4\u591a\u79cd RAG \u6280\u672f\u7684\u8bc4\u4f30\u3002\u5176\u4e2d\u63d0\u5230 HyDE \u548c LLM re-rank \u80fd\u591f\u5f88\u597d\u7684\u63d0\u9ad8\u68c0\u7d22\u7cbe\u5ea6\u3002\u4e0d\u8fc7\u4f3c\u4e4e HyDE \u5176\u5b9e\u8ba8\u8bba\u5e76\u4e0d\u662f\u5f88\u591a\uff0c\u90a3\u4e48\u54b1\u5c31\u5bf9\u8fd9\u5757\u5185\u5bb9\u6dfb\u7816\u52a0\u74e6\u4e00\u4e0b\uff0c\u8ba9\u6211\u4eec\u4ece\u96f6\u5f00\u59cb\u8fdb\u884c\u4e00\u6bb5 HyDE \u7684\u5192\u9669\u3002<\/p>\n<h2 id=\"\u4ec0\u4e48\u662f-rag\">\u4ec0\u4e48\u662f RAG\uff1f\n<\/h2><p>\u5927\u8bed\u8a00\u6a21\u578b(LLM)\u867d\u7136\u5728\u8fc7\u53bb\u7684\u4e00\u6bb5\u65f6\u95f4\u4e2d\u6210\u4e3a\u5927\u5bb6\u773c\u4e2d\u7684\u9999\u998d\u998d\uff0c\u4f46\u5b83\u4eec\u4e5f\u5b58\u5728\u4e00\u4e9b\u5173\u952e\u7684\u5c40\u9650\u6027:<\/p>\n<ul>\n<li><strong>\u77e5\u8bc6\u5c40\u9650\u6027<\/strong>: LLM \u7684\u77e5\u8bc6\u8303\u56f4\u4e3b\u8981\u5c40\u9650\u4e8e\u5176\u8bad\u7ec3\u6570\u636e\uff0c\u96be\u4ee5\u6db5\u76d6\u6240\u6709\u77e5\u8bc6\u9886\u57df\uff0c\u5728\u4e00\u4e9b\u4e13\u4e1a\u6216\u51b7\u95e8\u8bdd\u9898\u4e0a\u8868\u73b0\u4e0d\u4f73\u3002\u5c24\u5176\u662f\u73b0\u5728 AI \u5e94\u7528\u573a\u666f\u9700\u8981\u4f7f\u7528\u6765\u81ea\u4e8e\u4f01\u4e1a\u5185\u90e8\u77e5\u8bc6\u5e93\u6216\u8005\u5916\u90e8\u77e5\u8bc6\u5e93\u4e2d\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u800c\u8fd9\u4e9b\u5185\u90e8\u77e5\u8bc6\u5e93\u5f80\u5f80\u662f\u4e0d\u5728\u5916\u90e8\u516c\u5f00\u7684\u3002<\/li>\n<li><strong>\u53ef\u9760\u6027\u95ee\u9898<\/strong>: LLM \u4f9d\u8d56\u4e8e\u6982\u7387\u6a21\u578b\u751f\u6210\u6587\u672c\uff0c\u7ed3\u679c\u96be\u514d\u5b58\u5728\u4e8b\u5b9e\u6027\u9519\u8bef\u6216\u7f3a\u4e4f\u53ef\u9760\u6027\uff0c\u5728\u67d0\u4e9b\u5173\u952e\u5e94\u7528\u4e2d\u5b58\u5728\u98ce\u9669\u3002\u6bd4\u5982\u4e4b\u524d\u7684<a class=\"link\" href=\"https:\/\/bc.ctvnews.ca\/air-canada-s-chatbot-gave-a-b-c-man-the-wrong-information-now-the-airline-has-to-pay-for-the-mistake-1.6769454\" target=\"_blank\" rel=\"noopener\"\n>\u52a0\u62ff\u5927\u822a\u7a7a\u8d54\u507f\u4e8b\u4ef6<\/a>\uff0c\u5c24\u5176\u662f\u5bf9\u654f\u611f\u7684\u9700\u8981\u6b63\u786e\u4fe1\u606f\u7684\u573a\u666f\uff0c\u4e00\u65e6\u51fa\u73b0\u9519\u8bef\u7684\u4fe1\u606f\u5f80\u5f80\u610f\u5473\u7740\u6f5c\u5728\u7684\u635f\u5931\u3002<\/li>\n<\/ul>\n<p>\u8981\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u662f\u7528 RAG \u6765\u5e2e\u52a9\u89e3\u51b3\u3002\u90a3\u4e48\uff0c\u4ec0\u4e48\u662f RAG \u5462\uff1f<\/p>\n<p>Retrieval-Augmented Generation (RAG) \u662f\u4e00\u79cd\u57fa\u4e8e\u68c0\u7d22\u7684\u751f\u6210\u5f0f\u6a21\u578b\uff0c\u5b83\u7ed3\u5408\u4e86\u68c0\u7d22\u5f0f\u548c\u751f\u6210\u5f0f\u7684\u4f18\u70b9\uff0c\u53ef\u4ee5\u5728\u751f\u6210\u5f0f\u6a21\u578b(Generative Model)\u4e2d\u5f15\u5165\u5916\u90e8\u77e5\u8bc6\u3002RAG \u6a21\u578b\u7531\u4e24\u90e8\u5206\u7ec4\u6210\uff1a\u4e00\u4e2a\u662f\u68c0\u7d22\u5668\uff0c\u53e6\u4e00\u4e2a\u662f\u751f\u6210\u5668\u3002\u68c0\u7d22\u5668\u8d1f\u8d23\u4ece\u77e5\u8bc6\u5e93\u4e2d\u68c0\u7d22\u76f8\u5173\u4fe1\u606f\uff0c\u751f\u6210\u5668\u5219\u8d1f\u8d23\u751f\u6210\u7b54\u6848\u3002\u4e0e\u4f20\u7edf\u7684\u5927\u8bed\u8a00\u6a21\u578b(LLM)\u4ec5\u4f9d\u9760\u81ea\u8eab\u6709\u9650\u7684\u77e5\u8bc6\u8fdb\u884c\u6587\u672c\u751f\u6210\u4e0d\u540c\uff0cRAG \u6a21\u578b\u80fd\u591f\u52a8\u6001\u5730\u4ece\u6d77\u91cf\u7684\u5916\u90e8\u77e5\u8bc6\u5e93\u4e2d\u68c0\u7d22\u76f8\u5173\u4fe1\u606f\uff0c\u5e76\u5c06\u8fd9\u4e9b\u4fe1\u606f\u878d\u5165\u5230\u751f\u6210\u8fc7\u7a0b\u4e2d\uff0c\u4ea7\u751f\u66f4\u52a0\u51c6\u786e\u3001\u8fde\u8d2f\u7684\u8f93\u51fa\u5185\u5bb9\u3002<\/p>\n<p>\u6362\u53e5\u8bdd\u8bf4\uff0c\u5f53\u7528\u6237\u63d0\u51fa\u4e00\u4e2a\u67e5\u8be2\u6216\u8005\u9700\u8981\u751f\u6210\u67d0\u79cd\u7c7b\u578b\u7684\u6587\u672c\u65f6\uff0cRAG \u6a21\u578b\u9996\u5148\u4f1a\u5229\u7528\u4e00\u4e2a\u4fe1\u606f\u68c0\u7d22\u5b50\u6a21\u5757\uff0c\u4ece\u77e5\u8bc6\u5e93\u4e2d\u68c0\u7d22\u51fa\u4e0e\u67e5\u8be2\u76f8\u5173\u7684\u4fe1\u606f\u3002\u7136\u540e\uff0cRAG \u7684\u751f\u6210\u5b50\u6a21\u5757\u4f1a\u7ed3\u5408\u8fd9\u4e9b\u68c0\u7d22\u5230\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u751f\u6210\u6700\u7ec8\u7684\u8f93\u51fa\u6587\u672c\u3002\u8fd9\u79cd\u7ed3\u5408\u68c0\u7d22\u548c\u751f\u6210\u7684\u65b9\u5f0f\uff0c\u4f7f RAG \u6a21\u578b\u80fd\u591f\u5f25\u8865\u4f20\u7edf LLM \u7684\u5c40\u9650\u6027\uff0c\u63d0\u9ad8\u751f\u6210\u5185\u5bb9\u7684\u51c6\u786e\u6027\u548c\u53ef\u9760\u6027\u3002<\/p>\n<p>\u7b80\u5355\u70b9\u6765\u8bf4\uff0cRAG \u7684\u57fa\u672c\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n<p><img src=\".\/2024\/04\/learn-hyde-from-scratch-1\/vanilla-rag.webp\"\nwidth=\"1527\"\nheight=\"654\"\nsrcset=\".\/2024\/04\/learn-hyde-from-scratch-1\/vanilla-rag_hu_585e302af977823d.webp 480w, .\/2024\/04\/learn-hyde-from-scratch-1\/vanilla-rag_hu_eae049ef4f12aef4.webp 1024w\"\nloading=\"lazy\"\nclass=\"gallery-image\"\ndata-flex-grow=\"233\"\ndata-flex-basis=\"560px\"\n><\/p>\n<h2 id=\"\u4ec0\u4e48\u662f-hyde\">\u4ec0\u4e48\u662f HyDE\uff1f\n<\/h2><p>\u4f46\u662f\u5728\u662f\u7528 RAG \u7684\u65f6\u5019\uff0c\u4f60\u5f80\u5f80\u4e5f\u4f1a\u9047\u5230\u4e00\u4e9b\u95ee\u9898\u3002<\/p>\n<p>\u8ba9\u6211\u4eec\u8bbe\u60f3\u4e00\u4e2a\u573a\u666f\uff1a\u6211\u4eec\u6709\u4e00\u4e2a\u77e5\u8bc6\u5e93\uff0c\u91cc\u9762\u5b58\u50a8\u4e86\u5927\u91cf\u7684\u6587\u6863\uff0c\u6211\u4eec\u5e0c\u671b\u4f7f\u7528 RAG \u6a21\u578b\u6765\u56de\u7b54\u7528\u6237\u7684\u95ee\u9898\u3002\u4f46\u662f\uff0c\u539f\u59cb\u7684 RAG \u53ea\u80fd\u5904\u7406\u77e5\u8bc6\u5e93\u4e2d\u5305\u542b\u7684\u6570\u636e\uff0c\u4f46\u662f\u5bf9\u4e8e\u77e5\u8bc6\u5e93\u4e2d\u4e0d\u5b58\u5728\u7684\u6570\u636e\uff0cRAG \u65e0\u6cd5\u5904\u7406\u3002\u6bd4\u8f83\u5e38\u89c1\u7684\u573a\u666f\u5305\u542b\u7528\u6237\u7684\u95ee\u7b54\u7cfb\u7edf\uff0c\u5e2e\u52a9\u4e2d\u5fc3\uff0c\u5bf9\u8bdd\u7cfb\u7edf\u7b49\u3002\u7528\u6237\u901a\u5e38\u5bf9\u4f60\u7684\u7cfb\u7edf\u6216\u8005\u4e13\u6709\u540d\u8bcd\u5e76\u4e0d\u4e86\u89e3\uff0c\u4ed6\u4eec\u901a\u5e38\u4f1a\u63d0\u51fa\u4e00\u4e9b\u6839\u636e\u81ea\u5df1\u7406\u89e3\u6216\u8005\u81ea\u5df1\u719f\u6089\u6982\u5ff5\u4e2d\u7684\u540d\u8bcd\u95ee\u9898\uff0c\u8fd9\u4e9b\u8868\u8fbe\u65b9\u5f0f\u53ef\u80fd\u5e76\u4e0d\u5728\u4f60\u7684\u77e5\u8bc6\u5e93\u4e2d\u3002\u8fd9\u65f6\u5019 RAG \u5c31\u65e0\u6cd5\u4ece\u77e5\u8bc6\u5e93\u4e2d\u68c0\u7d22\u5230\u76f8\u5173\u4fe1\u606f\u3002<\/p>"},{"title":"No GIL Python \u7684\u5192\u9669","link":"https:\/\/www.4async.com\/2024\/03\/adventure-of-no-gil-python\/","pubDate":"Mon, 18 Mar 2024 10:11:00 +0000","guid":"https:\/\/www.4async.com\/2024\/03\/adventure-of-no-gil-python\/","description":"<img src=\"https:\/\/www.4async.com\/2024\/03\/adventure-of-no-gil-python\/cover.png\" alt=\"Featured image of post No GIL Python \u7684\u5192\u9669\" \/><p>\u5728\u524d\u51e0\u5468\u7684\u65f6\u5019\uff0cPython\u7684<a class=\"link\" href=\"https:\/\/github.com\/python\/cpython\/pull\/116338\" target=\"_blank\" rel=\"noopener\"\n>\u5141\u8bb8\u7981\u7528 GIL PR<\/a> \u6b63\u5f0f\u5408\u5e76\u8fdb\u5165\u4e86 Python 3.13 \u7684master\u5206\u652f\u3002\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684 PR\uff0c\u56e0\u4e3a\u5b83\u5728\u672a\u6765\u5c06\u4f1a\u5bf9 Python \u7684\u5e76\u53d1\u6027\u80fd\u4ea7\u751f\u975e\u5e38\u5927\u7684\u5f71\u54cd\u3002\u5728\u5373\u5c06\u5230\u6765\u7684 Python 3.13 \u4e2d\uff0c\u8fd9\u4e2a\u5141\u8bb8\u7981\u7528 GIL\u548c\u5305\u542b\u4e86 Copy and Paste JIT \u6280\u672f\uff0c\u8fd9\u4e9b\u540c\u65f6\u90fd\u5bf9 Python \u7684\u6027\u80fd\u4ea7\u751f\u4e86\u975e\u5e38\u5927\u7684\u5f71\u54cd\u3002<\/p>\n<h2 id=\"\u4ec0\u4e48\u662f-gil\">\u4ec0\u4e48\u662f GIL\n<\/h2><p>GIL\uff0c\u5373\u5168\u5c40\u89e3\u91ca\u5668\u9501\uff0c\u662f Python \u8bed\u8a00\u4e2d\u4e00\u4e2a\u6280\u672f\u672f\u8bed\u3002\u5b98\u65b9\u5b9e\u73b0\u7684 CPython \u4e2d\u5305\u542b\u4e86 GIL \u7684\u5b9e\u73b0\uff0c\u540c\u65f6\u4e5f\u662f\u6700\u5e7f\u6cdb\u4f7f\u7528\u7684\u5b9e\u73b0\u3002GIL \u7684\u4e3b\u8981\u76ee\u7684\u662f\u5728\u4efb\u4f55\u65f6\u5019\u53ea\u5141\u8bb8\u4e00\u4e2a\u7ebf\u7a0b\u6267\u884c Python \u5b57\u8282\u7801\uff0c\u8fd9\u610f\u5473\u7740\u5373\u4f7f\u4f60\u7684\u7a0b\u5e8f\u5728\u591a\u6838\u5904\u7406\u5668\u4e0a\u8fd0\u884c\uff0c\u4e5f\u65e0\u6cd5\u5b9e\u73b0\u771f\u6b63\u7684\u5e76\u884c\u6267\u884c\u3002GIL \u7684\u5b58\u5728\u4e3b\u8981\u662f\u4e3a\u4e86\u7b80\u5316 CPython \u7684\u5185\u5b58\u7ba1\u7406\u3002Python \u7684\u5bf9\u8c61\uff0c\u5982\u5217\u8868\u3001\u5b57\u5178\u7b49\uff0c\u4e0d\u662f\u7ebf\u7a0b\u5b89\u5168\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5982\u679c\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u4ece\u4e0d\u540c\u7684\u6838\u5fc3\u4fee\u6539\u540c\u4e00\u4e2a\u5bf9\u8c61\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6570\u636e\u4e0d\u4e00\u81f4\u6216\u8005\u7a0b\u5e8f\u5d29\u6e83\u3002GIL \u901a\u8fc7\u9650\u5236\u540c\u65f6\u6267\u884c\u7684\u7ebf\u7a0b\u6570\u6765\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002<\/p>\n<p>\u6362\u53e5\u8bdd\u8bf4\uff1a\u5982\u679c\u4e00\u4e2a\u7cfb\u7edf\u7ebf\u7a0b\u60f3\u8981\u6267\u884c Python \u7684\u5b57\u8282\u7801\uff0c\u5fc5\u987b\u8981\u83b7\u53d6\u5230 GIL \u9501\uff0c\u7136\u540e\u624d\u53ef\u4ee5\u6267\u884c Python \u5b57\u8282\u7801\u3002\u800c\u5982\u679c\u6ca1\u6709\u83b7\u53d6\u5230\u9501\uff0c\u90a3\u4e48\u7ebf\u7a0b\u5c31\u4f1a\u4f11\u7720\uff0c\u76f4\u5230\u83b7\u5f97\u4fe1\u53f7\u800c\u88ab\u5524\u9192\u3002\u4e3a\u4e86\u4fdd\u8bc1 Python \u7684\u6548\u7387\uff0cPython \u4e5f\u4f1a\u81ea\u52a8\u5207\u6362\u7ebf\u7a0b\uff0c\u6bd4\u5982 IO \u963b\u585e\u65f6\uff0c\u6216\u8005\u6267\u884c\u4e86\u6307\u5b9a\u6570\u91cf\u7684 Python \u5b57\u8282\u7801\u65f6\u3002\u8fd9\u6837\u5c31\u5c3d\u91cf\u4fdd\u8bc1\u4e86 Python \u7684\u6548\u7387\u3002\u5f53\u7136\uff0c\u4f60\u4e5f\u53ef\u4ee5\u9009\u62e9\u624b\u5de5\u91ca\u653e GIL \u9501\uff0c\u6bd4\u5982\u4f7f\u7528 C\/C++\/Rust \u6269\u5c55\uff0c\u6216\u8005\u4f7f\u7528 Cython \u7b49\u5f00\u53d1\u9ad8\u6027\u80fd\u6269\u5c55\u65f6\u3002<\/p>\n<p>\u4f46\u662f\u8fd9\u4e2a GIL \u4e5f\u662f Python \u7684\u4e00\u4e2a\u74f6\u9888\uff0c\u56e0\u4e3a\u5b83\u9650\u5236\u4e86 Python \u7684\u5e76\u53d1\u6027\u80fd\u3002\u5728\u591a\u6838\u5904\u7406\u5668\u4e0a\uff0cPython \u7684\u5e76\u53d1\u6027\u80fd\u5e76\u4e0d\u662f\u5f88\u597d\u3002\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u5f88\u591a\u4eba\u9009\u62e9\u4f7f\u7528\u591a\u8fdb\u7a0b\u800c\u4e0d\u662f\u591a\u7ebf\u7a0b\u6765\u63d0\u9ad8 Python \u7684\u5e76\u53d1\u6027\u80fd\u3002\u5728\u73b0\u4ee3\u7684\u8ba1\u7b97\u673a\u4e0a\uff0c\u591a\u6838\u5904\u7406\u5668\u5df2\u7ecf\u662f\u6807\u914d\uff0c\u56e0\u6b64 Python \u7684\u5e76\u53d1\u6027\u80fd\u6210\u4e3a\u4e86\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u95ee\u9898\u3002\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u8fd9\u4e48\u591a\u5e74\u6765\uff0cPython \u7684 GIL \u4e00\u76f4\u662f\u4e00\u4e2a\u975e\u5e38\u70ed\u95e8\u7684\u8bdd\u9898\u3002<\/p>"},{"title":"\u4f7f\u7528 Ollama \u5feb\u901f\u90e8\u7f72\u672c\u5730\u5f00\u6e90\u5927\u8bed\u8a00\u6a21\u578b","link":"https:\/\/www.4async.com\/2024\/02\/deploy-local-llm-using-ollama\/","pubDate":"Wed, 28 Feb 2024 17:39:00 +0000","guid":"https:\/\/www.4async.com\/2024\/02\/deploy-local-llm-using-ollama\/","description":"<img src=\"https:\/\/www.4async.com\/2024\/02\/deploy-local-llm-using-ollama\/cover.png\" alt=\"Featured image of post \u4f7f\u7528 Ollama \u5feb\u901f\u90e8\u7f72\u672c\u5730\u5f00\u6e90\u5927\u8bed\u8a00\u6a21\u578b\" \/><p>\u5982\u679c\u4f60\u662f\u7b2c\u4e00\u6b21\u5f00\u59cb\u7814\u7a76\u5982\u4f55\u4f7f\u7528\u5f00\u6e90\u5927\u8bed\u8a00\u6a21\u578b(LLM)\u6d4b\u8bd5 GenerativeAI \u65f6\uff0c\u4e00\u5f00\u59cb\u6240\u6709\u7684\u4fe1\u606f\u4e00\u80a1\u8111\u5728\u4f60\u7684\u773c\u524d\uff0c\u4ee4\u4eba\u671b\u800c\u751f\u754f\u3002\u4e92\u8054\u7f51\u4e0a\u5b58\u5728\u7740\u6765\u81ea\u8bb8\u591a\u4e0d\u540c\u6765\u6e90\u7684\u5927\u91cf\u788e\u7247\u4fe1\u606f\uff0c\u4f7f\u5f97\u5feb\u901f\u542f\u52a8\u9879\u76ee\u53d8\u5f97\u56f0\u96be\u3002<\/p>\n<p>\u8fd9\u7bc7\u6587\u7ae0\u7684\u76ee\u6807\u662f\u63d0\u4f9b\u4e00\u7bc7\u7b80\u6613\u4e0a\u624b\u7684\u6587\u7ae0\uff0c\u5e2e\u52a9\u4f60\u4f7f\u7528\u540d\u4e3a Ollama \u7684\u6a21\u578b\u7684\u542f\u52a8\u7a0b\u5e8f\u5728\u672c\u5730\u8bbe\u7f6e\u548c\u8fd0\u884c\u5f00\u6e90 AI \u6a21\u578b\uff0c\u5f53\u7136\uff0c\u8fd9\u4e9b\u6b65\u9aa4\u4e5f\u540c\u6837\u53ef\u4ee5\u8ba9\u4f60\u5728\u4f60\u7684\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u5b83\u3002<\/p>\n<h2 id=\"\u4ec0\u4e48\u662f-ollama\">\u4ec0\u4e48\u662f Ollama\n<\/h2><p>Ollama \u662f\u4e00\u6b3e\u5e2e\u52a9\u6211\u4eec\u5728\u672c\u5730\u673a\u5668\u4e0a\u8fd0\u884c\u5927\u578b\u8bed\u8a00\u6a21\u578b\u7684\u5de5\u5177\uff0c\u5b83\u8ba9\u4f60\u5728\u672c\u5730\u6d4b\u8bd5 LLM \u53d8\u5f97\u66f4\u52a0\u5bb9\u6613\u3002Ollama \u63d0\u4f9b\u4e86\u672c\u5730\u547d\u4ee4\u884c\u548c API \u8c03\u7528\u591a\u79cd\u65b9\u5f0f\u8fdb\u884c\u4ea4\u4e92\u3002\u5982\u679c\u4f60\u662f\u60f3\u5feb\u901f\u6d4b\u8bd5\uff0c\u90a3\u4e48 CLI \u5219\u662f\u4e00\u4e2a\u975e\u5e38\u4e0d\u9519\u7684\u65b9\u5f0f\uff1b\u5982\u679c\u4f60\u662f\u60f3\u5f00\u59cb\u4e00\u4e2a\u4ea7\u54c1\uff0c\u4f60\u4e5f\u53ef\u4ee5\u9009\u62e9\u8bd5\u7528<code>\/api\/chat<\/code>\u8fdb\u884c\u5f00\u53d1\u4e00\u4e2a\u5e94\u7528\u3002<\/p>\n<p>Ollama \u5206\u4e3a\u4e24\u4e2a\u90e8\u5206\uff1a\u4e00\u4e2a\u662f\u8fd0\u884c LLM \u7684\u670d\u52a1\u7aef\uff0c\u53e6\u5916\u4e00\u4e2a\u5219\u662f\u53ef\u9009\u7ec4\u4ef6\uff1a\u7528\u4e8e\u548c\u670d\u52a1\u7aef\u548c LLM\u8fdb\u884c\u4ea4\u4e92\u7684 CLI\u3002<\/p>\n<h3 id=\"\u5b89\u88c5-ollama\">\u5b89\u88c5 Ollama\n<\/h3><p><a class=\"link\" href=\"https:\/\/ollama.com\/\" target=\"_blank\" rel=\"noopener\"\n>Ollama<\/a> \u5b98\u65b9\u63d0\u4f9b\u4e86<a class=\"link\" href=\"https:\/\/ollama.com\/download\" target=\"_blank\" rel=\"noopener\"\n>\u5b89\u88c5\u5305<\/a>\u7528\u4e8e MacOS\/Linux\/Windows \u4e0b\u8f7d\u3002\u5176\u4e2d Windows \u652f\u6301\u622a\u6b62\u5230\u76ee\u524d(2024\/02\/27)\u4e3a\u6b62\uff0c\u8fd8\u662f\u9884\u89c8\u652f\u6301\uff0c\u53ef\u80fd\u5b58\u5728\u95ee\u9898\u3002\u56e0\u6b64\u8fd9\u91cc\u6211\u4eec\u6f14\u793a\u4f7f\u7528 MacOS \u5b89\u88c5\u8fd9\u4e2a\u5e94\u7528\u3002<\/p>\n<h4 id=\"\u4e0b\u8f7d\u5b89\u88c5\">\u4e0b\u8f7d\u5b89\u88c5\n<\/h4><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u89e3\u538b\u8fd9\u4e2a zip \u6587\u4ef6\u5373\u53ef\u5f97\u5230Ollama \u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u4f60\u53ef\u4ee5\u628a\u5b83\u62d6\u5230\u7cfb\u7edf\u7684\u5e94\u7528\u7a0b\u5e8f\u6587\u4ef6\u5939\u4e2d\uff0c\u53cc\u51fb\u6253\u5f00\uff1a<\/p>\n<p><img src=\"https:\/\/res.craft.do\/user\/full\/1adcdc5f-9fec-35eb-9cb6-9d25a1858140\/doc\/AC77186B-279D-42E3-94E6-1210D21445CF\/7F776093-3862-4581-8084-8B3BA0E87381_2\/xtp78WzaqBigmWTxPFklpEhcyiwIjyJ6WBYdsoYkN6oz\/Image.png\"\nloading=\"lazy\"\nalt=\"image\"\n><\/p>\n<p>\u5982\u679c\u662f\u7b2c\u4e00\u6b21\u6253\u5f00\uff0c\u4f1a\u9047\u5230\u5b89\u5168\u63d0\u793a\uff0c\u9009\u62e9\u6253\u5f00\u5373\u53ef\u3002<\/p>\n<p><img src=\"https:\/\/res.craft.do\/user\/full\/1adcdc5f-9fec-35eb-9cb6-9d25a1858140\/doc\/AC77186B-279D-42E3-94E6-1210D21445CF\/47F99D14-8F4F-4C2F-AEED-71C8F8894B2C_2\/glL5swE2IRE6DUeLCVYDYywm0ksnNLB1FxhstNkbAGwz\/2024-02-27%2011.44.33.png\"\nloading=\"lazy\"\nalt=\"image\"\n><\/p>\n<p>\u63a5\u4e0b\u6765\u9700\u8981\u5b89\u88c5 Ollama \u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u8fd9\u6837\u4f60\u5c31\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8bbf\u95eeLLM \u4e86\u3002<\/p>\n<p><img src=\"https:\/\/res.craft.do\/user\/full\/1adcdc5f-9fec-35eb-9cb6-9d25a1858140\/doc\/AC77186B-279D-42E3-94E6-1210D21445CF\/043C01CF-0F92-4B75-A566-43CFDAB1E541_2\/rOmbRmEOsdZek1JwIw5fDvoMAy6eUli2mziQFEEWTKwz\/2024-02-27%2011.46.18.png\"\nloading=\"lazy\"\nalt=\"image\"\n><\/p>\n<h4 id=\"\u547d\u4ee4\u884c\u5b89\u88c5\">\u547d\u4ee4\u884c\u5b89\u88c5\n<\/h4><p>\u5f53\u7136\uff0c\u5982\u679c\u4f60\u5b89\u88c5\u4e86<code>[homebrew](https:\/\/brew.sh\/)<\/code>\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u65b9\u5f0f\u5feb\u901f\u5b89\u88c5 Ollama\uff1a<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-python\" data-lang=\"python\"><span style=\"display:flex;\"><span>brew install ollama\n<\/span><\/span><\/code><\/pre><\/div><p>\u547d\u4ee4\u884c\u65b9\u5f0f\u5b89\u88c5\u65f6\uff0c\u9700\u8981\u989d\u5916\u6ce8\u610f\u6211\u4eec\u65e0\u6cd5\u50cf\u56fe\u5f62\u754c\u9762\u8fdb\u884c\u540e\u53f0\u670d\u52a1\u542f\u52a8\u3002\u4f60\u9700\u8981\u65bd\u5de5\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u542f\u52a8Ollama \u670d\u52a1\u7aef\uff1a<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-python\" data-lang=\"python\"><span style=\"display:flex;\"><span>ollama serve\n<\/span><\/span><\/code><\/pre><\/div><h2 id=\"\u8bd5\u7528-ollama\">\u8bd5\u7528 Ollama\n<\/h2><p>\u73b0\u5728\u4f60\u5df2\u7ecf\u5b89\u88c5\u5b8c\u6210 Ollama \u4e86\uff0c\u63a5\u4e0b\u6765\u8ba9\u6211\u4eec\u8fd0\u884c\u4e00\u4e2a\u57fa\u7840\u7684\u6a21\u578b\u8bd5\u7528\u4e00\u4e0b\u3002Ollama \u652f\u6301\u4e86<a class=\"link\" href=\"https:\/\/ollama.com\/library\" target=\"_blank\" rel=\"noopener\"\n>\u5f88\u591a\u7684\u5f00\u6e90\u6a21\u578b<\/a>\uff0c\u5305\u62ec Google \u6700\u65b0\u5f00\u6e90\u7684 <a class=\"link\" href=\"https:\/\/ollama.com\/library\/gemma\" target=\"_blank\" rel=\"noopener\"\n>Gemma<\/a>\u3002\u4e0d\u8fc7\u8fd9\u91cc\u6211\u63a8\u8350\u4f7f\u7528<a class=\"link\" href=\"https:\/\/ollama.com\/library\/mistral\" target=\"_blank\" rel=\"noopener\"\n>Mistral<\/a> 7B \u6a21\u578b\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u5feb\u901f\u5b89\u88c5\u5bf9\u5e94\u6a21\u578b\uff1a<\/p>"},{"title":"\u4f7f\u7528\u5b50\u89e3\u91ca\u5668\u8fd0\u884cPython\u5e76\u884c\u5e94\u7528","link":"https:\/\/www.4async.com\/2023\/11\/python-312-sub-interpreters\/","pubDate":"Thu, 23 Nov 2023 09:39:00 +0000","guid":"https:\/\/www.4async.com\/2023\/11\/python-312-sub-interpreters\/","description":"<img src=\"https:\/\/www.4async.com\/2023\/11\/python-312-sub-interpreters\/cover.webp\" alt=\"Featured image of post \u4f7f\u7528\u5b50\u89e3\u91ca\u5668\u8fd0\u884cPython\u5e76\u884c\u5e94\u7528\" \/><blockquote>\n<p>\u8bd1\u8005\u6ce8\uff1a\u6700\u8fd1 Python 3.12 \u5f15\u5165\u4e86\u5b50\u89e3\u91ca\u5668\u6982\u5ff5\uff0c\u975e\u5e38\u706b\u70ed\uff0c\u66f4\u597d\u7684\u6d88\u606f\u662f\u5df2\u7ecf<a class=\"link\" href=\"https:\/\/twitter.com\/anthonypjshaw\/status\/1723916190202945761\" target=\"_blank\" rel=\"noopener\"\n>\u5728FastAPI\u5e94\u7528\u6210\u529f<\/a>\u4e86\uff0c\u867d\u7136\u662f\u5f88\u7b80\u5355\u7684\u90a3\u79cd\u3002\u56e0\u6b64\u987a\u817e\u6478\u74dc\uff0c\u627e\u5230\u4e86\u4f5c\u8005\u7684<a class=\"link\" href=\"https:\/\/tonybaloney.github.io\/posts\/sub-interpreter-web-workers.html\" target=\"_blank\" rel=\"noopener\"\n>\u535a\u5ba2<\/a>\uff0c\u7ffb\u8bd1\u5206\u4eab\u7ed9\u5927\u5bb6\u3002<\/p><\/blockquote>\n<p>Python 3.12 \u5f15\u5165\u4e86\u4e00\u4e2a\u65b0\u7684 API \u7528\u4e8e\u201c\u5b50\u89e3\u91ca\u5668\u201d\uff08sub interpreters\uff09\uff0c\u8fd9\u662f Python \u7684\u4e00\u79cd\u4e0d\u540c\u7684\u5e76\u884c\u6267\u884c\u6a21\u578b\uff0c\u63d0\u4f9b\u4e86\u771f\u6b63\u5e76\u884c\u5904\u7406\u548c\u591a\u8fdb\u7a0b\u5904\u7406\u4e4b\u95f4\u7684\u826f\u597d\u6298\u4e2d\uff0c\u4e14\u5177\u6709\u66f4\u5feb\u7684\u542f\u52a8\u65f6\u95f4\u3002\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5c06\u89e3\u91ca\u4ec0\u4e48\u662f\u5b50\u89e3\u91ca\u5668\uff0c\u4e3a\u4ec0\u4e48\u5b83\u5bf9 Python \u4e2d\u7684\u5e76\u884c\u4ee3\u7801\u6267\u884c\u5f88\u91cd\u8981\uff0c\u4ee5\u53ca\u5b83\u4e0e\u5176\u4ed6\u65b9\u6cd5\u7684\u6bd4\u8f83\u3002<\/p>\n<h2 id=\"\u4ec0\u4e48\u662f\u5b50\u89e3\u91ca\u5668\">\u4ec0\u4e48\u662f\u5b50\u89e3\u91ca\u5668\uff1f\n<\/h2><p>Python \u7684\u7cfb\u7edf\u67b6\u6784\u5927\u81f4\u7531\u4e09\u90e8\u5206\u7ec4\u6210\uff1a<\/p>\n<ul>\n<li>\u4e00\u4e2a\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u89e3\u91ca\u5668\u7684 Python \u8fdb\u7a0b<\/li>\n<li>\u4e00\u4e2a\u5305\u542b\u9501\uff08GIL\uff09\u548c\u4e00\u4e2a\u6216\u591a\u4e2a Python \u7ebf\u7a0b\u7684\u89e3\u91ca\u5668<\/li>\n<li>\u4e00\u4e2a\u5305\u542b\u5f53\u524d\u6267\u884c\u4ee3\u7801\u4fe1\u606f\u7684\u7ebf\u7a0b\u3002<\/li>\n<\/ul>\n<p><img src=\".\/2023\/11\/python-312-sub-interpreters\/interpreter-states-1.png\"\nwidth=\"2111\"\nheight=\"1898\"\nsrcset=\".\/2023\/11\/python-312-sub-interpreters\/interpreter-states-1_hu_e139c5bca93ea465.png 480w, .\/2023\/11\/python-312-sub-interpreters\/interpreter-states-1_hu_a52b647e9e8156e1.png 1024w\"\nloading=\"lazy\"\nalt=\"interpreter states\"\nclass=\"gallery-image\"\ndata-flex-grow=\"111\"\ndata-flex-basis=\"266px\"\n><\/p>\n<p>\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u8fd9\u65b9\u9762\u7684\u4fe1\u606f\uff0c\u4f60\u53ef\u4ee5\u9605\u8bfb\u6211\u7684\u4e66<a class=\"link\" href=\"https:\/\/tonybaloney.github.io\/#books\" target=\"_blank\" rel=\"noopener\"\n>\u300aCPython \u5185\u90e8\u5b9e\u73b0\u300b<\/a>\u4e2d\u7684\u201c\u5e76\u884c\u6027\u548c\u5e76\u53d1\u6027\u201d\u7ae0\u8282\u3002<\/p>\n<p>\u81ea Python 1.5 \u4ee5\u6765\uff0c\u5c31\u6709\u4e00\u4e2a C-API \u53ef\u4ee5\u652f\u6301\u591a\u4e2a\u89e3\u91ca\u5668\uff0c\u4f46\u8fd9\u4e2a\u529f\u80fd\u7531\u4e8e GIL \u7684\u9650\u5236\u800c\u53d7\u5230\u4e25\u91cd\u9650\u5236\uff0c\u6ca1\u6709\u771f\u6b63\u5b9e\u73b0\u771f\u6b63\u7684\u5e76\u884c\u6027\u3002\u56e0\u6b64\uff0c\u8fd0\u884c\u5e76\u884c\u4ee3\u7801\u6700\u5e38\u7528\u7684\u6280\u672f\uff08\u4e0d\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\uff09\u662f\u4f7f\u7528 <a class=\"link\" href=\"https:\/\/docs.python.org\/3\/library\/multiprocessing.html\" target=\"_blank\" rel=\"noopener\"\n>multiprocessing \u6a21\u5757<\/a>\u3002<\/p>\n<p>2017 \u5e74\uff0cCPython \u6838\u5fc3\u5f00\u53d1\u4eba\u5458\u63d0\u51fa\u6539\u53d8\u89e3\u91ca\u5668\u7ed3\u6784\u7684\u63d0\u8bae\uff0c\u4f7f\u5b83\u4eec\u66f4\u597d\u5730\u4e0e\u62e5\u6709\u5b83\u4eec\u7684 Python \u8fdb\u7a0b\u9694\u79bb\uff0c\u5e76\u80fd\u591f\u5e76\u884c\u64cd\u4f5c\u3002\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u7684\u5de5\u4f5c\u76f8\u5f53\u5de8\u5927\uff086 \u5e74\u540e\u4ecd\u672a\u5b8c\u6210\uff09\uff0c\u5e76\u5206\u4e3a\u4e24\u4e2a PEP\u3002PEP684 \u5c06 GIL \u5728\u5404\u4e2a\u89e3\u91ca\u5668\u72ec\u7acb\u5f00\uff0cPEP554 \u63d0\u4f9b\u4e86\u4e00\u4e2a\u521b\u5efa\u89e3\u91ca\u5668\u548c\u5728\u5b83\u4eec\u4e4b\u95f4\u5171\u4eab\u6570\u636e\u7684 API\u3002<\/p>\n<p>GIL \u662f\u201c\u5168\u5c40\u89e3\u91ca\u5668\u9501\u201d\uff0c\u662f Python \u8fdb\u7a0b\u4e2d\u7684\u4e00\u4e2a\u9501\uff0c\u610f\u5473\u7740\u5728\u4efb\u4f55\u65f6\u95f4\u70b9 Python \u8fdb\u7a0b\u4e2d\u53ea\u80fd\u6267\u884c\u4e00\u6761\u6307\u4ee4\uff0c\u5373\u4f7f\u5b83\u6709\u591a\u4e2a\u7ebf\u7a0b\u3002\u8fd9\u5b9e\u9645\u4e0a\u610f\u5473\u7740\uff0c\u5373\u4f7f\u4f60\u5728\u62e5\u6709 4 \u6838 CPU \u7684\u7535\u8111\u4e0a\u540c\u65f6\u542f\u52a8 4 \u4e2a Python \u7ebf\u7a0b\uff0c\u4e5f\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u4f1a\u5728\u4efb\u4f55\u65f6\u5019\u8fd0\u884c\u3002<\/p>"},{"title":"Twirp\u521d\u76f8\u8bc6","link":"https:\/\/www.4async.com\/2023\/01\/twirp-first-step\/","pubDate":"Wed, 25 Jan 2023 09:39:00 +0000","guid":"https:\/\/www.4async.com\/2023\/01\/twirp-first-step\/","description":"<img src=\"https:\/\/www.4async.com\/2023\/01\/twirp-first-step\/cover.png\" alt=\"Featured image of post Twirp\u521d\u76f8\u8bc6\" \/><h2 id=\"\u4ec0\u4e48\u662ftwirp\">\u4ec0\u4e48\u662fTwirp\uff1f\n<\/h2><p>Twirp\u662fTwitch\u5728<a class=\"link\" href=\"https:\/\/blog.twitch.tv\/en\/2018\/01\/16\/twirp-a-sweet-new-rpc-framework-for-go-5f2febbf35f\/\" target=\"_blank\" rel=\"noopener\"\n>2018\u5e74<\/a>\u5f00\u6e90\u7684RPC\u6846\u67b6\u3002\u6b63\u5982\u540c\u4ed6\u4eec\u5728\u53d1\u5e03\u6587\u7ae0\u4e2d\u8bf4\u7684\u90a3\u6837\uff0cRPC\u76f8\u5bf9\u4e8e\u666e\u901a\u7684RESTful API\u66f4\u65b9\u4fbf\u8bbe\u8ba1\u3001\u7ec4\u7ec7\u548c\u7ef4\u62a4\uff0c\u8ba9\u5f00\u53d1\u8005\u66f4\u52a0\u4e13\u6ce8\u4e8e\u4e1a\u52a1\u3002\u4f46\u662f\u540c\u6837\u7684\uff0c\u5728Go\u793e\u533a\u4e2d\u91cd\u8981\u7684gRPC\u65b9\u6848\u4e25\u91cd\u4e0eHTTP\/2\u7ed1\u5b9a\uff0c\u8fd9\u4e5f\u6210\u4e3a\u4e00\u4e2a\u5236\u7ea6\u5176\u63a8\u5e7f\u7684\u95ee\u9898\uff1aHTTP\/2\u7684\u590d\u6742\u6027\u5176\u5b9e\u5e76\u4e0d\u5fc5\u8981\uff1b\u4e0eGo Runtime\u7684\u5272\u88c2\u4e5f\u662f\u53e6\u5916\u4e00\u4e2a\u95ee\u9898\uff0c\u5bfc\u81f4\u90e8\u5206\u4f18\u5316\u96be\u4ee5\u76f4\u63a5\u901a\u8fc7\u5347\u7ea7Go\u7248\u672c\u5728gRPC\u4e0a\u663e\u73b0\u3002<\/p>\n<p>Twirp\u5219\u9009\u62e9\u4fdd\u7559\u4e86\u90e8\u5206\u597d\u7684\u5730\u65b9\uff1a\u4f7f\u7528Protobuf\u8fd9\u4e2aIDL\u7ea6\u675f\u8bf7\u6c42\/\u8fd4\u56de\u7c7b\u578b\uff0c\u8fd9\u6837\u53ef\u4ee5\u6700\u5927\u5316\u501f\u52a9Protobuf\u5e26\u6765\u7684\u4f18\u52bf\uff0c\u751f\u6210\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u4ee3\u7801\u3002\u4f46\u662fTwirp\u9009\u62e9\u4e0eGo\u6807\u51c6\u5e93\u96c6\u6210\uff0c\u8fd9\u6837\u53ef\u4ee5\u66f4\u597d\u7684\u5229\u7528Go\u672c\u8eab\u5347\u7ea7\u5e26\u6765\u7684\u4f18\u5316\u3002\u8fd9\u540c\u65f6\u4e5f\u4fdd\u8bc1\u4e86Twirp\u672c\u8eab\u7684\u7b80\u6d01\u6027\u3002\u540c\u65f6\uff0c\u4f60\u4e5f\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u4f7f\u7528cURL\u7b49\u4f20\u7edf\u5de5\u5177\uff0c\u501f\u52a9json\u8bf7\u6c42\u6d4b\u8bd5\uff0c\u800c\u4e0d\u9700\u8981\u624b\u5de5\u5904\u7406\u4e8c\u8fdb\u5236\u6570\u636e\u3002\u540c\u6837\u7684\uff0c\u501f\u52a9Go\u6807\u51c6\u5e93\uff0c\u672a\u6765Twirp\u53ef\u4ee5\u66f4\u597d\u7684\u5347\u7ea7\u6210HTTP\/3\u800c\u4e0d\u662f\u50cfgRPC\u4e00\u6837\u7b49\u5f85\u4e0a\u6e38\u66f4\u65b0\u3002\u5f53\u7136\u5982\u679c\u4f60\u66f4\u503e\u5411\u4e8e\u4f7f\u7528gRPC\u76f8\u5173\u7684\u5b9e\u8df5\uff0c\u90a3\u4e48<a class=\"link\" href=\"https:\/\/buf.build\/blog\/connect-a-better-grpc\" target=\"_blank\" rel=\"noopener\"\n>connect-go<\/a>\u53ef\u80fd\u662f\u4f60\u7684\u53e6\u5916\u4e00\u4e2a\u4e0d\u9519\u9009\u62e9\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u5982\u679c\u8bf4\u7f3a\u70b9\uff0cTwirp\u5e76\u4e0d\u5b8c\u7f8e\uff1a\u5c0f\u4f17\u7684\u793e\u533a\uff0c\u7f3a\u5c11\u751f\u6001\uff0c\u7f3a\u5c11\u76f8\u5173\u4fe1\u606f\u5185\u5bb9\u7b49\u7b49\u3002\u4e0d\u8fc7\u8fd9\u4e9b\u4ecd\u65e7\u662f\u7455\u4e0d\u63a9\u745c\u3002\u6bd5\u7adf\u5b9e\u73b0\u4e00\u4e2a\u76f8\u5173\u7684\u529f\u80fd\u5176\u5b9e\u5e76\u4e0d\u90a3\u4e48\u590d\u6742\u3002<\/p>\n<h2 id=\"\u5982\u4f55\u4f7f\u7528twirp\">\u5982\u4f55\u4f7f\u7528Twirp\n<\/h2><p>Twirp\u867d\u7136\u5b98\u7f51\u6bd4\u8f83\u7b80\u5355\uff0c\u751a\u81f3\u793e\u533a\u4e5f\u4e0d\u662f\u5f88\u5927\u7684\u6837\u5b50\uff0c\u4f46\u662f\u57fa\u672c\u4e0a\u9700\u6c42\u7684\u6570\u636e\u57fa\u672c\u90fd\u53ef\u4ee5\u5728\u5b98\u7f51\u4e0a\u627e\u5230\u5165\u53e3\u3002\u4f46\u662f\u8fd9\u4e5f\u6709\u4e2a\u95ee\u9898\uff0c\u5bfc\u81f4\u6574\u4e2a\u6d41\u7a0b\u5bf9\u65b0\u624b\u5e76\u4e0d\u53cb\u597d\uff0c\u6709\u6bd4\u8f83\u9ad8\u7684\u4e0a\u624b\u95e8\u69db\u3002\u63a5\u4e0b\u6765\u7684\u5185\u5bb9\u4e3b\u8981\u662f\u5b8c\u5584\u8fd9\u90e8\u5206\u7684\u5185\u5bb9\uff0c\u65b9\u4fbf\u65b0\u624b\u7528\u6237\u4f7f\u7528\u3002<\/p>\n<h3 id=\"\u5b89\u88c5protobuf\u76f8\u5173\u5de5\u5177\">\u5b89\u88c5Protobuf\u76f8\u5173\u5de5\u5177\n<\/h3><p>\u7531\u4e8eTwirp\u540c\u6837\u4f7f\u7528Protobuf\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528\u76f8\u5173\u5de5\u5177\u3002\u9996\u5148\u662fProtobuf\uff0c\u63a5\u4e0b\u6765\u662f\u4e00\u4e9bprotoc-gen\u5de5\u5177\uff1a<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-Bash\" data-lang=\"Bash\"><span style=\"display:flex;\"><span>brew install protobuf <span style=\"color:#75715e\"># Mac Only<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>go install google.golang.org\/protobuf\/cmd\/protoc-gen-go@latest\n<\/span><\/span><span style=\"display:flex;\"><span>go install github.com\/twitchtv\/twirp\/protoc-gen-twirp@latest\n<\/span><\/span><\/code><\/pre><\/div><h4 id=\"\u53ef\u9009\u9879buf\">\u53ef\u9009\u9879\uff1aBuf\n<\/h4><p>Buf\u662f\u4e00\u4e2aProtobuf\u7ba1\u7406\u5de5\u5177\uff0c\u5e2e\u52a9\u4f60\u5b9e\u73b0<a class=\"link\" href=\"https:\/\/99designs.com.au\/blog\/engineering\/schema-driven-development\/\" target=\"_blank\" rel=\"noopener\"\n>Schema Driven Development<\/a>\u5b9e\u8df5\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2aCLI\u7ba1\u7406\u5de5\u5177\uff08\u652f\u6301lint\uff0c\u751f\u6210\u548c\u7834\u574f\u6027\u68c0\u67e5\u7b49\u529f\u80fd\uff09\u548c\u7c7b\u4f3c\u6ce8\u518c\u4e2d\u5fc3\u673a\u5236\u7684BSR(Buf Schema Registry)\uff0c\u4f60\u53ef\u4ee5\u5728\u8fd9\u91cc\u7ba1\u7406\u4f60\u7684Schema\u7248\u672c\u548c\u5f15\u7528\u5176\u4ed6\u516c\u5f00\u670d\u52a1\u7684Schema\u3002\u4e0d\u4f7f\u7528Buf\u5e76\u4e0d\u4f1a\u5e26\u6765\u529f\u80fd\u7f3a\u5931\uff0c\u5e76\u4e14Buf\u63d0\u4f9b\u4e86<a class=\"link\" href=\"https:\/\/buf.build\/pricing\" target=\"_blank\" rel=\"noopener\"\n>\u4ed8\u8d39SaaS\u670d\u52a1<\/a>(\u6d4b\u8bd5\u671f\u95f4\u514d\u8d39)\uff0c\u53ef\u4ee5\u6839\u636e\u4f60\u7684\u60c5\u51b5\u9009\u62e9\u662f\u5426\u4f7f\u7528\u3002<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-Bash\" data-lang=\"Bash\"><span style=\"display:flex;\"><span>brew install bufbuild\/buf\/buf <span style=\"color:#75715e\"># Mac Only<\/span>\n<\/span><\/span><\/code><\/pre><\/div><h4 id=\"\u53ef\u9009\u9879taskfile\">\u53ef\u9009\u9879\uff1aTaskfile\n<\/h4><p><a class=\"link\" href=\"https:\/\/taskfile.dev\/\" target=\"_blank\" rel=\"noopener\"\n>Taskfile<\/a>\u662f\u6211\u5e38\u7528\u6765\u66ff\u4ee3Makefile\u7684\u5de5\u5177\u3002\u8fd9\u5e76\u4e0d\u662f\u5fc5\u987b\u7684\u5de5\u5177\uff0c\u4f60\u540c\u6837\u53ef\u4ee5\u4f7f\u7528\u624b\u5de5\u6267\u884c\u547d\u4ee4\u884c\u548cMakefile\u547d\u4ee4\u8fdb\u884c\u3002\u4e8b\u5b9e\u4e0a\uff0c\u4f7f\u7528Makefile\u5176\u5b9e\u53ef\u4ee5\u66f4\u597d\u7684\u5728Jenkins\u4e4b\u7c7b\u7684pipeline\u91cc\u6267\u884c\uff0c\u4f46\u662f\u5bf9Github Action\u7b49\u73b0\u4ee3pipeline\u800c\u8a00\uff0c\u533a\u522b\u5e76\u4e0d\u5927\u3002<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-Bash\" data-lang=\"Bash\"><span style=\"display:flex;\"><span>brew install go-task\/tap\/go-task <span style=\"color:#75715e\"># Mac Only<\/span>\n<\/span><\/span><\/code><\/pre><\/div><h3 id=\"\u751f\u6210\u9879\u76ee\u6587\u4ef6\">\u751f\u6210\u9879\u76ee\u6587\u4ef6\n<\/h3><p>\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684Greeter\u7a0b\u5e8f\u6f14\u793a\u4f7f\u7528\u3002\u5047\u8bbe\u6211\u4eec\u5df2\u7ecf\u5b58\u5728\u4e86\u4e00\u4e2aGo\u7684\u7a7a\u9879\u76ee\uff0c\u90a3\u4e48\u6211\u4eec\u63a5\u4e0b\u6765\u9700\u8981\u521b\u5efa\u5bf9\u5e94\u7684\u76ee\u5f55\u548c\u6587\u4ef6\u3002\u6309\u7167<a class=\"link\" href=\"https:\/\/twitchtv.github.io\/twirp\/docs\/best_practices.html#folderpackage-structure\" target=\"_blank\" rel=\"noopener\"\n>\u5b98\u65b9\u7684\u5efa\u8bae<\/a>\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u7ed3\u6784\u521b\u5efa\u6211\u4eec\u7684\u9879\u76ee\uff0c\u4f60\u53ef\u4ee5\u5728Github\u4e0a\u67e5\u770b<a class=\"link\" href=\"https:\/\/github.com\/ipfans\/twirp-demo\" target=\"_blank\" rel=\"noopener\"\n>\u5b8c\u6574\u7684\u4ee3\u7801<\/a>\uff1a<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-Bash\" data-lang=\"Bash\"><span style=\"display:flex;\"><span>$ tree .\n<\/span><\/span><span style=\"display:flex;\"><span>.\n<\/span><\/span><span style=\"display:flex;\"><span>\u251c\u2500\u2500 README.md\n<\/span><\/span><span style=\"display:flex;\"><span>\u251c\u2500\u2500 Taskfile.yaml\n<\/span><\/span><span style=\"display:flex;\"><span>\u251c\u2500\u2500 buf.gen-ts.yaml\n<\/span><\/span><span style=\"display:flex;\"><span>\u251c\u2500\u2500 buf.gen.yaml\n<\/span><\/span><span style=\"display:flex;\"><span>\u251c\u2500\u2500 buf.yaml\n<\/span><\/span><span style=\"display:flex;\"><span>\u251c\u2500\u2500 build\n<\/span><\/span><span style=\"display:flex;\"><span>\u251c\u2500\u2500 client\n<\/span><\/span><span style=\"display:flex;\"><span>\u2502 \u251c\u2500\u2500 package.json\n<\/span><\/span><span style=\"display:flex;\"><span>\u2502 \u251c\u2500\u2500 pnpm-lock.yaml\n<\/span><\/span><span style=\"display:flex;\"><span>\u2502 \u2514\u2500\u2500 src\n<\/span><\/span><span style=\"display:flex;\"><span>\u2502 \u2514\u2500\u2500 protoc-gen-twirp-es.ts\n<\/span><\/span><span style=\"display:flex;\"><span>\u251c\u2500\u2500 cmd\n<\/span><\/span><span style=\"display:flex;\"><span>\u2502 \u2514\u2500\u2500 greeter\n<\/span><\/span><span style=\"display:flex;\"><span>\u2502 \u251c\u2500\u2500 main.go\n<\/span><\/span><span style=\"display:flex;\"><span>\u2502 \u2514\u2500\u2500 main_test.go\n<\/span><\/span><span style=\"display:flex;\"><span>\u251c\u2500\u2500 go.mod\n<\/span><\/span><span style=\"display:flex;\"><span>\u251c\u2500\u2500 go.sum\n<\/span><\/span><span style=\"display:flex;\"><span>\u251c\u2500\u2500 internal\n<\/span><\/span><span style=\"display:flex;\"><span>\u2502 \u2514\u2500\u2500 greetersvc\n<\/span><\/span><span style=\"display:flex;\"><span>\u2502 \u2514\u2500\u2500 service.go\n<\/span><\/span><span style=\"display:flex;\"><span>\u2514\u2500\u2500 rpc\n<\/span><\/span><span style=\"display:flex;\"><span> \u2514\u2500\u2500 greeter\n<\/span><\/span><span style=\"display:flex;\"><span> \u2514\u2500\u2500 v1\n<\/span><\/span><span style=\"display:flex;\"><span> \u2514\u2500\u2500 service.proto\n<\/span><\/span><\/code><\/pre><\/div><h2 id=\"\u7f16\u5199\u670d\u52a1\u7aef\">\u7f16\u5199\u670d\u52a1\u7aef\n<\/h2><p>\u6211\u4eec\u5148\u770b\u4e00\u4e0bgreeter\u7684\u670d\u52a1\u5b9a\u4e49\uff1a<\/p>"},{"title":"Twirp\u57fa\u672c\u6982\u5ff5\uff1aHooks\u548cInterceptors","link":"https:\/\/www.4async.com\/2023\/01\/twirp-hooks-and-interceptors\/","pubDate":"Wed, 25 Jan 2023 09:39:00 +0000","guid":"https:\/\/www.4async.com\/2023\/01\/twirp-hooks-and-interceptors\/","description":"<img src=\"https:\/\/www.4async.com\/2023\/01\/twirp-hooks-and-interceptors\/cover.png\" alt=\"Featured image of post Twirp\u57fa\u672c\u6982\u5ff5\uff1aHooks\u548cInterceptors\" \/><p>Twirp\u505a\u4e86\u8db3\u591f\u591a\u7684\u62bd\u8c61\u5de5\u4f5c\uff0c\u4f7f\u5f97\u6211\u4eec\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u5c42\u6b21\u4e0a\u8fdb\u884c\u6269\u5c55\u3002\u5728\u6700\u57fa\u7840\u7684\u4f7f\u7528\u5c42\u9762\u4e0a\uff0c\u4f60\u53ef\u4ee5\u50cf<code>net\/http<\/code>\u4e00\u6837\u53bb\u7b80\u5355\u7684\u4f7f\u7528\u3002\u4f46\u662f\u5f80\u5f80\u8fd9\u6837\u4e5f\u4e0d\u80fd\u6ee1\u8db3\u6211\u4eec\u5b9e\u9645\u9879\u76ee\u4e2d\u7684\u9700\u6c42\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecdTwirp\u7684Hooks\u548cInterceptors\u57fa\u672c\u6982\u5ff5\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9bTwirp\u7684\u6269\u5c55\u673a\u5236\u3002<\/p>\n<h2 id=\"\">\n<\/h2>"},{"title":"\u53bb\u5e74\u7684\u4e00\u70b9\u5c0f\u5de5\u4f5c(1)\uff1a\u4eceBFF\u8c08\u8d77","link":"https:\/\/www.4async.com\/2023\/01\/something-happend-in-2022-1\/","pubDate":"Sat, 21 Jan 2023 17:55:39 +0000","guid":"https:\/\/www.4async.com\/2023\/01\/something-happend-in-2022-1\/","description":"<img src=\"https:\/\/www.4async.com\/2023\/01\/something-happend-in-2022-1\/cover.jpg\" alt=\"Featured image of post \u53bb\u5e74\u7684\u4e00\u70b9\u5c0f\u5de5\u4f5c(1)\uff1a\u4eceBFF\u8c08\u8d77\" \/><p>\u524d\u5e74\u5e95\uff0c\u4e4b\u524d\u521b\u4e1a\u7684\u516c\u53f8\u5173\u6389\u6b63\u5f0f\u56de\u5f52\u4e86\u6253\u5de5\u751f\u6d3b\u3002\u73b0\u5728\u5728\u4e00\u5bb6SaaS\u516c\u53f8\u505a\u4e00\u4e9b\u65b0\u4e1a\u52a1\u5f00\u53d1\u548c\u67b6\u6784\u7684\u5de5\u4f5c\u3002\u8fd9\u4e2a\u7cfb\u5217\u7684\u6587\u7ae0\u4e5f\u662f\u60f3\u6574\u7406\u4e00\u4e0b2022\u5e74\u7684\u4e00\u4e9b\u5c0f\u6210\u679c\uff0c\u6709\u4e00\u4e9b\u5185\u5bb9\u548c\u76f8\u5173\u80cc\u666f\u53ef\u80fd\u56e0\u4e3a\u5404\u79cd\u539f\u56e0\u65e0\u6cd5\u63cf\u8ff0\u66f4\u7ec6\u8282\u7684\u5185\u5bb9\uff0c\u4e5f\u8bf7\u5404\u4f4d\u89c1\u8c05\u3002<\/p>\n<h1 id=\"\u540e\u7aef\u548c\u524d\u7aef\u7684\u914d\u5408\u6211\u4eec\u9047\u5230\u4e86\u4ec0\u4e48\u95ee\u9898\">\u540e\u7aef\u548c\u524d\u7aef\u7684\u914d\u5408\uff0c\u6211\u4eec\u9047\u5230\u4e86\u4ec0\u4e48\u95ee\u9898\uff1f\n<\/h1>"},{"title":"Byebye 2022, Hello 2023","link":"https:\/\/www.4async.com\/2023\/01\/byebye-2022-hello-2023\/","pubDate":"Sun, 01 Jan 2023 17:53:39 +0000","guid":"https:\/\/www.4async.com\/2023\/01\/byebye-2022-hello-2023\/","description":"<img src=\"https:\/\/www.4async.com\/2023\/01\/byebye-2022-hello-2023\/2022-2023.jpg\" alt=\"Featured image of post Byebye 2022, Hello 2023\" \/>"},{"title":"\u7ed9hugo\u6dfb\u52a0mermaid\u652f\u6301","link":"https:\/\/www.4async.com\/2022\/12\/add-mermaid-support-for-hugo\/","pubDate":"Mon, 26 Dec 2022 17:48:00 +0000","guid":"https:\/\/www.4async.com\/2022\/12\/add-mermaid-support-for-hugo\/","description":"<img src=\"https:\/\/www.4async.com\/2022\/12\/add-mermaid-support-for-hugo\/gohugo.png\" alt=\"Featured image of post \u7ed9hugo\u6dfb\u52a0mermaid\u652f\u6301\" \/><p>\u53d1\u73b02022\u5e74\u5c45\u7136\u4e00\u7bc7\u535a\u5ba2\u90fd\u6ca1\u5199\uff0c\u4e00\u65b9\u9762\u662f\u75ab\u60c5\u539f\u56e0\u5b9e\u5728\u592a\u7cdf\u5fc3\uff0c\u53e6\u5916\u4e00\u65b9\u9762\u662f\u73af\u5883\u4f7f\u7136\uff0c2022\u5e74\u4e00\u5e74\u90fd\u5728\u9002\u5e94\u65b0\u73af\u5883\u548c\u62fc\u547d\u7684\u63a8\u52a8\u9879\u76ee\u524d\u884c\u3002\u7acb\u4e2aFlag\uff0c\u4fdd\u8bc1\u660e\u5e74\u81f3\u5c11\u4e00\u4e2a\u5b63\u5ea6\u6709\u4e00\u7bc7\u6587\u7ae0\u5427\u3002<\/p>\n<p>\u8fd9\u7bc7\u6587\u7ae0\u662f\u4e3a\u4e86\u63d0\u793a\u5982\u4f55\u5728hugo\u4e2d\u6dfb\u52a0mermaid\u652f\u6301\uff0cmermaid\u662f\u4e00\u4e2a\u6d41\u7a0b\u56fe\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5728markdown\u4e2d\u76f4\u63a5\u4f7f\u7528\uff0c\u975e\u5e38\u65b9\u4fbf\u3002\u5176\u5b9e\u5728hugo\u5b98\u65b9\u6587\u6863\u4e2d\u5df2\u7ecf\u6709\u4e86\u8bf4\u660e\uff0c\u4f46\u662f\u6211\u5728\u4f7f\u7528\u7684\u65f6\u5019\u53d1\u73b0\u5bf9\u65b0\u4eba\u4e0d\u662f\u7279\u522b\u53cb\u597d\uff0c\u6240\u4ee5\u8fd9\u91cc\u8bb0\u5f55\u4e00\u4e0b\uff0c\u987a\u4fbf\u6c34\u4e00\u4e2a\u3002<\/p>"},{"title":"\u4e00\u4e9b\u5b9e\u7528\u5de5\u5177\u5217\u8868","link":"https:\/\/www.4async.com\/2021\/11\/awesome-toolkit\/","pubDate":"Mon, 29 Nov 2021 17:48:00 +0000","guid":"https:\/\/www.4async.com\/2021\/11\/awesome-toolkit\/","description":"<img src=\"https:\/\/www.4async.com\/2021\/11\/awesome-toolkit\/toolkit.png\" alt=\"Featured image of post \u4e00\u4e9b\u5b9e\u7528\u5de5\u5177\u5217\u8868\" \/><p>\u4e00\u4e9b\u5728\u5de5\u4f5c\u4e2d\u7ecf\u5e38\u4f7f\u7528\u7684\u4e00\u4e9b\u5de5\u5177\u3002\u5982\u679c\u6709\u4ec0\u4e48\u63a8\u8350\u7684\uff0c\u4e5f\u6b22\u8fce\u5728\u8bc4\u8bba\u4e2d\u63d0\u4f9b\u3002\u8fd9\u4e2a\u5217\u8868\u540e\u7eed\u4f1a\u6301\u7eed\u66f4\u65b0<\/p>\n<h2 id=\"http\u5de5\u5177\">HTTP\u5de5\u5177\n<\/h2><ul>\n<li><a class=\"link\" href=\"https:\/\/curlie.io\" target=\"_blank\" rel=\"noopener\"\n><strong>curlie<\/strong><\/a> - httpie-like \u5de5\u5177\uff0c\u5e95\u5c42\u662fcurl<\/li>\n<li><a class=\"link\" href=\"https:\/\/github.com\/go-acme\/lego\" target=\"_blank\" rel=\"noopener\"\n><strong>lego<\/strong><\/a> - Let&rsquo;s Encrypt\u8bc1\u4e66\u5de5\u5177<\/li>\n<li><a class=\"link\" href=\"https:\/\/github.com\/FiloSottile\/mkcert\" target=\"_blank\" rel=\"noopener\"\n><strong>mkcert<\/strong><\/a> - \u65b9\u4fbf\u5bfc\u5165\u672c\u5730\u8bc1\u4e66<\/li>\n<li><a class=\"link\" href=\"https:\/\/paw.cloud\" target=\"_blank\" rel=\"noopener\"\n><strong>paw.cloud<\/strong><\/a> - \u539f\u751f\u7684macOS HTTP\u8c03\u8bd5\u5de5\u5177\uff0c\u73b0\u5728\u6bcf\u5e74\u90fd\u4f1a\u514d\u8d39\u9001\uff0c\u6709\u5174\u8da3\u5173\u6ce8\u4e00\u4e0b<\/li>\n<\/ul>\n<h2 id=\"\u7f16\u8bd1\u5de5\u5177\">\u7f16\u8bd1\u5de5\u5177\n<\/h2><ul>\n<li><a class=\"link\" href=\"https:\/\/taskfile.dev\" target=\"_blank\" rel=\"noopener\"\n><strong>go-task<\/strong><\/a> - \u6211\u7528\u6765\u66ff\u4ee3Makefile\uff0c\u5e76\u65e0\u4ec0\u4e48\u7279\u6b8a\u5fc5\u8981\uff0c\u4e3b\u8981\u662f\u4e0d\u60f3\u5199Makefile<\/li>\n<\/ul>\n<h2 id=\"\u4ee3\u7801\u8d28\u91cf\">\u4ee3\u7801\u8d28\u91cf\n<\/h2><ul>\n<li><a class=\"link\" href=\"https:\/\/github.com\/golangci\/golangci-lint\" target=\"_blank\" rel=\"noopener\"\n><strong>golangci-lint<\/strong><\/a> - \u611f\u89c9\u65e0\u9700\u4ecb\u7ecd\u4e86\uff0c\u96c6\u6210\u4e86\u5f88\u591a\u5b9e\u7528\u5de5\u5177\uff0c\u91cd\u590d\u7684\u5c31\u4e0d\u5217\u4e3e\u4e86<\/li>\n<li><a class=\"link\" href=\"https:\/\/pre-commit.com\" target=\"_blank\" rel=\"noopener\"\n><strong>pre-commit<\/strong><\/a> - \u63d0\u4ea4\u524d\u68c0\u67e5\u4ee3\u7801\u8d28\u91cf\uff0c\u6bd4\u5982\u4ee3\u7801\u98ce\u683c\uff0c\u7f29\u8fdb\uff0c\u7a7a\u683c\u7b49\u7b49<\/li>\n<li><a class=\"link\" href=\"https:\/\/github.com\/boyter\/dcd\" target=\"_blank\" rel=\"noopener\"\n><strong>dcd<\/strong><\/a> - \u67e5\u627e\u4ee3\u7801\u4e2d\u7684\u91cd\u590d\u4ee3\u7801<\/li>\n<\/ul>\n<h2 id=\"\u4ee3\u7801\u7edf\u8ba1\">\u4ee3\u7801\u7edf\u8ba1\n<\/h2><ul>\n<li><a class=\"link\" href=\"https:\/\/github.com\/boyter\/scc\" target=\"_blank\" rel=\"noopener\"\n><strong>scc<\/strong><\/a> - \u9ad8\u6027\u80fd\u7edf\u8ba1\u4ee3\u7801\u884c\u6570<\/li>\n<\/ul>\n<h2 id=\"\u56fe\u8868\u5de5\u5177\">\u56fe\u8868\u5de5\u5177\n<\/h2><ul>\n<li><a class=\"link\" href=\"https:\/\/github.com\/blushft\/go-diagrams\" target=\"_blank\" rel=\"noopener\"\n><strong>go-diagrams<\/strong><\/a> - \u4f7f\u7528Go\u8bed\u8a00\u63cf\u8ff0\u7cfb\u7edf\u67b6\u6784\u56fe<\/li>\n<li><a class=\"link\" href=\"https:\/\/github.com\/k1LoW\/ndiag\" target=\"_blank\" rel=\"noopener\"\n><strong>ndiag<\/strong><\/a> - \u5982\u679c\u4e0d\u60f3\u7528Go\u63cf\u8ff0\uff0c\u4e5f\u53ef\u4ee5\u9009\u62e9\u7528YAML\u63cf\u8ff0\u7cfb\u7edf\u67b6\u6784<\/li>\n<li><a class=\"link\" href=\"https:\/\/github.com\/lucasepe\/draft\" target=\"_blank\" rel=\"noopener\"\n><strong>draft<\/strong><\/a> - \u53e6\u5916\u4e00\u4e2a\u7528YAML\u63cf\u8ff0\u7684\u5de5\u5177\uff0c\u98ce\u683c\u4e0d\u4e00\u6837<\/li>\n<li><a class=\"link\" href=\"https:\/\/github.com\/mkimuram\/k8sviz\" target=\"_blank\" rel=\"noopener\"\n><strong>k8sviz<\/strong><\/a> - \u4f60\u4e5f\u53ef\u4ee5\u4ece\u73b0\u6210\u7684K8s\u73af\u5883\u4e2d\u751f\u6210\u7cfb\u7edf\u67b6\u6784\u56fe<\/li>\n<li><a class=\"link\" href=\"https:\/\/github.com\/storj\/archview\" target=\"_blank\" rel=\"noopener\"\n><strong>archview<\/strong><\/a> - \u901a\u8fc7\u4ee3\u7801\u4e2d\u6ce8\u91ca\u751f\u6210\u5e94\u7528\u5185\u90e8\u5206\u5c42\u7ed3\u6784<\/li>\n<li><a class=\"link\" href=\"https:\/\/github.com\/bykof\/go-plantuml\" target=\"_blank\" rel=\"noopener\"\n><strong>go-plantuml<\/strong><\/a> - \u6839\u636eGo\u4ee3\u7801\u751f\u6210\u7ed3\u6784\u4f53\u7684PlantUML\u56fe<\/li>\n<li><a class=\"link\" href=\"https:\/\/github.com\/jfeliu007\/goplantuml\" target=\"_blank\" rel=\"noopener\"\n><strong>goplantuml<\/strong><\/a> - \u53e6\u5916\u4e00\u79cd\u751f\u6210PlantUML\u7684\u5de5\u5177<\/li>\n<li><a class=\"link\" href=\"https:\/\/github.com\/gmarik\/go-erd\" target=\"_blank\" rel=\"noopener\"\n><strong>go-erd<\/strong><\/a> - \u4e0d\u60f3\u7528PlantUML\u4e5f\u53ef\u4ee5\u6362\u8fd9\u79cd\u98ce\u683c<\/li>\n<li><a class=\"link\" href=\"https:\/\/asciiflow.com\" target=\"_blank\" rel=\"noopener\"\n><strong>asciiflow<\/strong><\/a> - \u53ef\u4ee5\u753bASCII\u56fe\uff0cASCII\u56fe\u597d\u5904\u662f\u53ef\u4ee5\u653e\u5728\u4ee3\u7801\u91cc\uff0c\u5982\u679c\u4f60\u613f\u610f\u7684\u8bdd<\/li>\n<li><a class=\"link\" href=\"https:\/\/textart.io\/sequence\" target=\"_blank\" rel=\"noopener\"\n><strong>sequence<\/strong><\/a> - \u5acc\u5f03asciiflow\u6bd4\u8f83\u539f\u59cb\uff0c\u505a\u65f6\u5e8f\u56fe\u7684\u65f6\u5019\u53ef\u4ee5\u7528\u8fd9\u4e2a<\/li>\n<li><a class=\"link\" href=\"https:\/\/mermaid-js.github.io\/mermaid-live-editor\/\" target=\"_blank\" rel=\"noopener\"\n><strong>mermaid-js<\/strong><\/a> - \u65b9\u4fbf\u96c6\u6210\u5728\u7f51\u9875\u4e2d\uff0c\u4e5f\u53ef\u4ee5\u5bfc\u51fa\u6210\u56fe\u7247<\/li>\n<li><a class=\"link\" href=\"https:\/\/kroki.io\/\" target=\"_blank\" rel=\"noopener\"\n><strong>kroki<\/strong><\/a> - \u4e0a\u9762\u6ca1\u63d0\u5230\u7684\u56fe\u7c7b\u578b\u7684\u751f\u6210\uff1f\u770b\u770b\u8fd9\u4e2a<\/li>\n<\/ul>\n<h2 id=\"iac\">IaC\n<\/h2><ul>\n<li><a class=\"link\" href=\"https:\/\/www.pulumi.com\/\" target=\"_blank\" rel=\"noopener\"\n><strong>pulumi<\/strong><\/a> - Terraform\u4e1a\u754c\u6bd4\u8f83\u5e38\u7528\uff0c\u4e0d\u8fc7\u8981\u5b66\u4e60HCL\u6bd4\u8f83\u86cb\u75bc\uff0c\u6211\u4e2a\u4eba\u6bd4\u8f83\u559c\u6b22pulumi\uff0c\u53ef\u4ee5\u9009\u62e9\u81ea\u5df1\u7684\u4e60\u60ef\u7684\u8bed\u8a00\uff0ctf-cdk\u76ee\u524d\u8fd8\u6bd4\u8f83\u521d\u7ea7\u3002<\/li>\n<\/ul>"},{"title":"Go 1.17 \u6cdb\u578b\u5c1d\u9c9c","link":"https:\/\/www.4async.com\/2021\/08\/golang-117-generics\/","pubDate":"Tue, 17 Aug 2021 17:48:00 +0000","guid":"https:\/\/www.4async.com\/2021\/08\/golang-117-generics\/","description":"<img src=\"https:\/\/www.4async.com\/2021\/08\/golang-117-generics\/go.png\" alt=\"Featured image of post Go 1.17 \u6cdb\u578b\u5c1d\u9c9c\" \/><p>\u4eca\u5929\uff0cGo\u76841.17\u7248\u672c\u7ec8\u4e8e\u6b63\u5f0f\u53d1\u5e03\uff0c\u9664\u4e86\u5e26\u6765\u5404\u79cd\u4f18\u5316\u548c\u65b0\u529f\u80fd\u5916\uff0c1.17\u6b63\u5f0f\u5728\u7a0b\u5e8f\u4e2d\u63d0\u4f9b\u4e86\u5c1d\u9c9c\u7684\u6cdb\u578b\u652f\u6301\uff0c\u8fd9\u4e00\u529f\u80fd\u4e5f\u662f\u4e3a1.18\u7248\u672c\u6cdb\u578b\u6b63\u5f0f\u5b9e\u88c5\u505a\u94fa\u57ab\u3002\u610f\u5473\u7740\u57286\u4e2a\u6708\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u6b63\u5f0f\u4f7f\u7528\u6cdb\u578b\u5f00\u53d1\u4e86\u3002\u90a3\u5728Go 1.18\u6b63\u5f0f\u5b9e\u88c5\u4e4b\u524d\uff0c\u6211\u4eec\u57281.17\u7248\u672c\u4e2d\u5148\u5c1d\u9c9c\u4e00\u4e0b\u6cdb\u578b\u7684\u652f\u6301\u5427\u3002<\/p>\n<h2 id=\"\u6cdb\u578b\u6709\u4ec0\u4e48\u4f5c\u7528\">\u6cdb\u578b\u6709\u4ec0\u4e48\u4f5c\u7528\uff1f\n<\/h2><p>\u5728\u4f7f\u7528Go\u6ca1\u6709\u6cdb\u578b\u4e4b\u524d\u6211\u4eec\u600e\u4e48\u5b9e\u73b0\u9488\u5bf9\u591a\u7c7b\u578b\u7684\u903b\u8f91\u5b9e\u73b0\u7684\u5462\uff1f\u6709\u5f88\u591a\u65b9\u6cd5\uff0c\u6bd4\u5982\u8bf4\u4f7f\u7528<code>interface{}<\/code>\u4f5c\u4e3a\u53d8\u91cf\u7c7b\u578b\u53c2\u6570\uff0c\u5728\u5185\u90e8\u901a\u8fc7\u7c7b\u578b\u5224\u65ad\u8fdb\u5165\u5bf9\u5e94\u7684\u5904\u7406\u903b\u8f91\uff1b\u5c06\u7c7b\u578b\u8f6c\u5316\u4e3a\u7279\u5b9a\u8868\u73b0\u7684\u9e2d\u5b50\u7c7b\u578b\uff0c\u901a\u8fc7\u63a5\u53e3\u5b9a\u4e49\u7684\u65b9\u6cd5\u5b9e\u73b0\u903b\u8f91\u6574\u5408\uff1b\u8fd8\u6709\u4eba\u4e13\u95e8\u7f16\u5199\u4e86Go\u7684<a class=\"link\" href=\"https:\/\/twitter.com\/yogthos\/status\/883058510275149826\" target=\"_blank\" rel=\"noopener\"\n>\u51fd\u6570\u4ee3\u7801\u751f\u6210\u5de5\u5177<\/a>\uff0c\u901a\u8fc7\u6279\u91cf\u751f\u6210\u4e0d\u540c\u7c7b\u578b\u7684\u76f8\u540c\u5b9e\u73b0\u51fd\u6570\u4ee3\u66ff\u624b\u5de5\u5b9e\u73b0\u7b49\u7b49\u3002\u8fd9\u4e9b\u65b9\u6cd5\u591a\u591a\u5c11\u5c11\u5b58\u5728\u4e00\u4e9b\u95ee\u9898\uff1a\u4f7f\u7528\u4e86<code>interface{}<\/code>\u4f5c\u4e3a\u53c2\u6570\u610f\u5473\u7740\u653e\u5f03\u4e86\u7f16\u8bd1\u65f6\u68c0\u67e5\uff0c\u4f5c\u4e3a\u5f3a\u7c7b\u578b\u8bed\u8a00\u7684\u4e00\u4e2a\u4f18\u52bf\u5c31\u88ab\u62b9\u6389\u4e86\u3002\u540c\u6837\uff0c\u65e0\u8bba\u4f7f\u7528\u4ee3\u7801\u751f\u6210\u8fd8\u662f\u624b\u5de5\u4e66\u5199\uff0c\u4e00\u65e6\u51fa\u73b0\u95ee\u9898\uff0c\u610f\u5473\u7740\u8fd9\u4e9b\u65b9\u6cd5\u90fd\u9700\u8981\u91cd\u590d\u751f\u6210\u6216\u8005\u8fdb\u884c\u6279\u91cf\u4fee\u6539\uff0c\u5de5\u4f5c\u91cf\u53cd\u800c\u53d8\u5f97\u66f4\u591a\u4e86\u3002<\/p>\n<p>\u5728Go\u4e2d\u5f15\u5165\u6cdb\u578b\u4f1a\u7ed9\u7a0b\u5e8f\u5f00\u53d1\u5e26\u6765\u5f88\u591a\u597d\u5904\uff1a\u901a\u8fc7\u6cdb\u578b\uff0c\u53ef\u4ee5\u9488\u5bf9\u591a\u79cd\u7c7b\u578b\u7f16\u5199\u4e00\u6b21\u4ee3\u7801\uff0c\u5927\u5927\u8282\u7701\u4e86\u7f16\u7801\u65f6\u95f4\u3002\u4f60\u53ef\u4ee5\u5145\u5206\u5e94\u7528\u7f16\u8bd1\u5668\u7684\u7f16\u8bd1\u68c0\u67e5\uff0c\u4fdd\u8bc1\u7a0b\u5e8f\u53d8\u91cf\u7c7b\u578b\u7684\u53ef\u9760\u6027\u3002\u501f\u52a9\u6cdb\u578b\uff0c\u4f60\u53ef\u4ee5\u51cf\u5c11\u4ee3\u7801\u7684\u91cd\u590d\u5ea6\uff0c\u4e5f\u4e0d\u4f1a\u51fa\u73b0\u4e00\u5904\u51fa\u73b0\u95ee\u9898\u9700\u8981\u4fee\u6539\u591a\u5904\u5730\u65b9\u7684\u5c34\u5c2c\u95ee\u9898\u3002\u8fd9\u4e5f\u8ba9\u5f88\u591a\u6d4b\u8bd5\u5de5\u4f5c\u53d8\u5f97\u66f4\u7b80\u5355\uff0c\u501f\u52a9\u7c7b\u578b\u5b89\u5168\uff0c\u4f60\u751a\u81f3\u53ef\u4ee5\u5c11\u8003\u8651\u5f88\u591a\u7684\u8fb9\u7f18\u60c5\u51b5\u3002<\/p>\n<p>Go\u8bed\u8a00\u5b98\u65b9\u6709\u8be6\u7ec6\u7684\u6cdb\u578b\u63d0\u6848\u6587\u6863\u53ef\u4ee5\u5728<a class=\"link\" href=\"https:\/\/go.googlesource.com\/proposal\/&#43;\/refs\/heads\/master\/design\/15292-generics.md\" target=\"_blank\" rel=\"noopener\"\n>\u8fd9\u91cc<\/a>\u548c<a class=\"link\" href=\"https:\/\/go.googlesource.com\/proposal\/&#43;\/refs\/heads\/master\/design\/15292\/2013-12-type-params.md\" target=\"_blank\" rel=\"noopener\"\n>\u8fd9\u91cc<\/a>\u67e5\u770b\u8be6\u60c5\u3002<\/p>\n<h2 id=\"\u5982\u4f55\u4f7f\u7528\u6cdb\u578b\">\u5982\u4f55\u4f7f\u7528\u6cdb\u578b\n<\/h2><p>\u524d\u9762\u7406\u8bba\u6211\u4eec\u4ec5\u4ec5\u53ea\u505a\u4ecb\u7ecd\uff0c\u8fd9\u6b21\u5c1d\u9c9c\u8fd8\u662f\u4ee5\u5b9e\u8df5\u4e3a\u4e3b\u3002\u8ba9\u6211\u4eec\u5148\u4ece\u4e00\u4e2a\u5c0f\u4f8b\u5b50\u5f00\u59cb\u3002<\/p>\n<h3 id=\"\u4ece\u7b80\u5355\u7684\u4f8b\u5b50\u5f00\u59cb\">\u4ece\u7b80\u5355\u7684\u4f8b\u5b50\u5f00\u59cb\n<\/h3><p>\u8ba9\u6211\u4eec\u5148\u4ece\u4e00\u4e2a\u6700\u7b80\u5355\u7684\u4f8b\u5b50\u5f00\u59cb\uff1a<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-go\" data-lang=\"go\"><span style=\"display:flex;\"><span><span style=\"color:#f92672\">package<\/span> <span style=\"color:#a6e22e\">main<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#f92672\">import<\/span> (\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#e6db74\">&#34;fmt&#34;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>)\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">type<\/span> <span style=\"color:#a6e22e\">Addable<\/span> <span style=\"color:#66d9ef\">interface<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#66d9ef\">type<\/span> <span style=\"color:#66d9ef\">int<\/span>, <span style=\"color:#66d9ef\">int8<\/span>, <span style=\"color:#66d9ef\">int16<\/span>, <span style=\"color:#66d9ef\">int32<\/span>, <span style=\"color:#66d9ef\">int64<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#66d9ef\">uint<\/span>, <span style=\"color:#66d9ef\">uint8<\/span>, <span style=\"color:#66d9ef\">uint16<\/span>, <span style=\"color:#66d9ef\">uint32<\/span>, <span style=\"color:#66d9ef\">uint64<\/span>, <span style=\"color:#66d9ef\">uintptr<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#66d9ef\">float32<\/span>, <span style=\"color:#66d9ef\">float64<\/span>, <span style=\"color:#66d9ef\">complex64<\/span>, <span style=\"color:#66d9ef\">complex128<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#66d9ef\">string<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">func<\/span> <span style=\"color:#a6e22e\">add<\/span>[<span style=\"color:#a6e22e\">T<\/span> <span style=\"color:#a6e22e\">Addable<\/span>](<span style=\"color:#a6e22e\">a<\/span>, <span style=\"color:#a6e22e\">b<\/span> <span style=\"color:#a6e22e\">T<\/span>) <span style=\"color:#a6e22e\">T<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#66d9ef\">return<\/span> <span style=\"color:#a6e22e\">a<\/span> <span style=\"color:#f92672\">+<\/span> <span style=\"color:#a6e22e\">b<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">func<\/span> <span style=\"color:#a6e22e\">main<\/span>() {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">fmt<\/span>.<span style=\"color:#a6e22e\">Println<\/span>(<span style=\"color:#a6e22e\">add<\/span>(<span style=\"color:#ae81ff\">1<\/span>,<span style=\"color:#ae81ff\">2<\/span>))\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">fmt<\/span>.<span style=\"color:#a6e22e\">Println<\/span>(<span style=\"color:#a6e22e\">add<\/span>(<span style=\"color:#e6db74\">&#34;1&#34;<\/span>, <span style=\"color:#e6db74\">&#34;2&#34;<\/span>))\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><p>\u8fd9\u4e2a\u51fd\u6570\u53ef\u4ee5\u5b9e\u73b0\u4efb\u4f55\u9700\u8981\u4f7f\u7528<code>+<\/code>\u7b26\u53f7\u8fdb\u884c\u8fd0\u7b97\u7684\u7c7b\u578b\uff0c\u6211\u4eec\u901a\u8fc7\u5b9a\u4e49<code>Addable<\/code>\u7c7b\u578b\uff0c\u679a\u4e3e\u4e86\u6240\u6709\u53ef\u80fd\u53ef\u4ee5\u4f7f\u7528<code>add<\/code>\u65b9\u6cd5\u7684\u6240\u6709\u7684\u7c7b\u578b\u3002\u6bd4\u5982\u6211\u4eec\u5728<code>main<\/code>\u51fd\u6570\u4e2d\u5c31\u4f7f\u7528\u4e86<code>int<\/code>\u548c<code>string<\/code>\u4e24\u79cd\u4e0d\u540c\u7c7b\u578b\u3002<\/p>\n<p>\u4f46\u662f\u5982\u679c\u8fd9\u65f6\u6211\u4eec\u4f7f\u7528\u7b80\u5355\u7684<code>go run<\/code>\u547d\u4ee4\u8fd0\u884c\uff0c\u4f1a\u53d1\u73b0\u63d0\u793a\u8bed\u6cd5\u9519\u8bef\uff1a<\/p>\n<pre tabindex=\"0\"><code>$ go version\ngo version go1.17 darwin\/arm64\n$ go run ~\/main.go\n# command-line-arguments\n..\/main.go:8:2: syntax error: unexpected type, expecting method or interface name\n..\/main.go:15:6: missing function body\n..\/main.go:15:9: syntax error: unexpected [, expecting (\n<\/code><\/pre><p>\u56e0\u4e3a\u5728Go 1.17\u4e2d\uff0c\u6cdb\u578b\u5e76\u672a\u9ed8\u8ba4\u5f00\u542f\uff0c\u4f60\u9700\u8981\u5b9a\u4e49<code>gcflags<\/code>\u65b9\u5f0f\u542f\u7528\u6cdb\u578b\uff1a<\/p>"},{"title":"Go Web\u5e94\u7528\u4e2d\u5e38\u89c1\u7684\u53cd\u6a21\u5f0f","link":"https:\/\/www.4async.com\/2021\/08\/common-anti-patterns-in-go-web-applications\/","pubDate":"Fri, 13 Aug 2021 14:09:00 +0000","guid":"https:\/\/www.4async.com\/2021\/08\/common-anti-patterns-in-go-web-applications\/","description":"<img src=\"https:\/\/www.4async.com\/2020\/02\/2020-02-16-moving-towards-domain-driven-design-in-go\/cover_huea63e6370dcf0c375755d886a5d0b9c6_97708_1600x0_resize_q75_box.jpg\" alt=\"Featured image of post Go Web\u5e94\u7528\u4e2d\u5e38\u89c1\u7684\u53cd\u6a21\u5f0f\" \/><blockquote>\n<p>\u4f5c\u8005\uff1aMi\u0142osz Sm\u00f3\u0142ka <br>\n\u8bd1\u8005\uff1aKevin <br>\n\u539f\u6587\u5730\u5740\uff1ahttps:\/\/threedots.tech\/post\/common-anti-patterns-in-go-web-applications\/<\/p><\/blockquote>\n<p>\u5728\u6211\u804c\u4e1a\u751f\u6daf\u7684\u67d0\u4e2a\u9636\u6bb5\uff0c\u6211\u5bf9\u6211\u6240\u6784\u5efa\u7684\u8f6f\u4ef6\u4e0d\u518d\u611f\u5230\u5174\u594b\u3002<\/p>\n<p>\u6211\u6700\u559c\u6b22\u7684\u5de5\u4f5c\u5185\u5bb9\u662f\u5e95\u5c42\u7684\u7ec6\u8282\u548c\u590d\u6742\u7684\u7b97\u6cd5\u3002\u5728\u8f6c\u5230\u9762\u5411\u7528\u6237\u7684\u5e94\u7528\u5f00\u53d1\u4e4b\u540e\uff0c\u8fd9\u4e9b\u5185\u5bb9\u57fa\u672c\u6d88\u5931\u4e86\u3002\u7f16\u7a0b\u4f3c\u4e4e\u662f\u5229\u7528\u73b0\u6709\u7684\u5e93\u548c\u5de5\u5177\u628a\u6570\u636e\u4ece\u4e00\u5904\u79fb\u81f3\u53e6\u4e00\u5904\u3002\u5230\u76ee\u524d\u4e3a\u6b62\uff0c\u6211\u6240\u5b66\u5230\u7684\u5173\u4e8e\u8f6f\u4ef6\u7684\u77e5\u8bc6\u4e0d\u518d\u90a3\u4e48\u6709\u7528\u4e86\u3002<\/p>\n<p>\u8ba9\u6211\u4eec\u9762\u5bf9\u73b0\u5b9e\u5427\uff1a\u5927\u591a\u6570Web\u5e94\u7528\u65e0\u6cd5\u89e3\u51b3\u68d8\u624b\u7684\u6280\u672f\u6311\u6218\u3002\u4ed6\u4eec\u9700\u8981\u505a\u5230\u7684\u662f\u6b63\u786e\u7684\u5bf9\u4ea7\u54c1\u8fdb\u884c\u5efa\u6a21\uff0c\u5e76\u4e14\u6bd4\u7ade\u4e89\u5bf9\u624b\u66f4\u5feb\u7684\u6539\u8fdb\u4ea7\u54c1\u3002<\/p>\n<p>\u8fd9\u8d77\u521d\u770b\u8d77\u6765\u4f3c\u4e4e\u662f\u90a3\u4e48\u7684\u65e0\u804a\uff0c\u4f46\u662f\u4f60\u5f88\u5feb\u4f1a\u610f\u8bc6\u5230\u5b9e\u73b0\u8fd9\u4e2a\u76ee\u6807\u6bd4\u542c\u8d77\u6765\u8981\u96be\u3002\u8fd9\u662f\u4e00\u9879\u5b8c\u5168\u4e0d\u540c\u7684\u6311\u6218\u3002\u5373\u4f7f\u5b83\u4eec\u6280\u672f\u4e0a\u5b9e\u73b0\u5e76\u6ca1\u6709\u90a3\u4e48\u590d\u6742\uff0c\u4f46\u65f6\u89e3\u51b3\u5b83\u4eec\u4f1a\u5bf9\u4ea7\u54c1\u4ea7\u751f\u5de8\u5927\u5f71\u54cd\u5e76\u4e14\u8ba9\u4eba\u83b7\u5f97\u6ee1\u8db3\u3002<\/p>\n<p><strong>Web\u5e94\u7528\u9762\u4e34\u7684\u6700\u5927\u6311\u6218\u4e0d\u662f\u53d8\u6210\u4e86\u4e00\u4e2a\u65e0\u6cd5\u7ef4\u62a4\u7684\u5c4e\u5c71\uff0c\u800c\u662f\u4f1a\u51cf\u6162\u4f60\u7684\u901f\u5ea6\uff0c\u8ba9\u4f60\u7684\u4e1a\u52a1\u6700\u7ec8\u5931\u8d25\u3002<\/strong><\/p>\n<p>\u8fd9\u662f\u4ed6\u4eec\u5982\u4f55\u5728Go\u4e2d\u53d1\u751f\u548c\u6211\u662f\u5982\u4f55\u907f\u514d\u4ed6\u4eec\u7684\u3002<\/p>\n<h2 id=\"\u677e\u8026\u5408\u662f\u5173\u952e\">\u677e\u8026\u5408\u662f\u5173\u952e\n<\/h2><p>\u5e94\u7528\u96be\u4ee5\u7ef4\u62a4\u7684\u4e00\u4e2a\u91cd\u8981\u539f\u56e0\u662f\u5f3a\u8026\u5408\u3002<\/p>\n<p><strong>\u5728\u5f3a\u8026\u5408\u5e94\u7528\u4e2d\uff0c\u4efb\u4f55\u4f60\u5c1d\u8bd5\u89e6\u52a8\u7684\u4e1c\u897f\u90fd\u6709\u53ef\u80fd\u4ea7\u751f\u610f\u60f3\u4e0d\u5230\u7684\u526f\u4f5c\u7528<\/strong>\u3002\u6bcf\u6b21\u91cd\u6784\u7684\u5c1d\u8bd5\u90fd\u4f1a\u53d1\u73b0\u65b0\u7684\u95ee\u9898\u3002\u6700\u7ec8\uff0c\u4f60\u51b3\u5b9a\u5b57\u53f7\u4ece\u5934\u91cd\u5199\u6574\u4e2a\u9879\u76ee\u3002\u5728\u4e00\u4e2a\u5feb\u901f\u589e\u957f\u7684\u4ea7\u54c1\u4e2d\uff0c\u4f60\u662f\u4e0d\u53ef\u80fd\u51bb\u7ed3\u6240\u6709\u7684\u5f00\u53d1\u4efb\u52a1\u53bb\u5b8c\u6210\u91cd\u5199\u5df2\u7ecf\u6784\u5efa\u7684\u5e94\u7528\u7684\u3002\u800c\u4e14\u4f60\u4e0d\u80fd\u4fdd\u8bc1\u8fd9\u6b21\u4f60\u628a\u6240\u6709\u4e8b\u90fd\u5b8c\u6210\u597d\u3002<\/p>\n<p>\u76f8\u6bd4\u4e4b\u4e0b\uff0c<strong>\u677e\u8026\u5408\u5e94\u7528\u4fdd\u6301\u4e86\u6e05\u6670\u7684\u8fb9\u754c<\/strong>\u3002\u4ed6\u4eec\u5141\u8bb8\u66f4\u6362\u4e00\u4e9b\u635f\u574f\u7684\u90e8\u5206\u4e0d\u5f71\u54cd\u9879\u76ee\u7684\u5176\u4ed6\u90e8\u5206\u3002\u5b83\u4eec\u66f4\u5bb9\u6613\u6784\u5efa\u548c\u7ef4\u62a4\u3002\u4f46\u662f\uff0c\u4e3a\u4ec0\u4e48\u4ed6\u4eec\u5982\u6b64\u7f55\u89c1\u5462\uff1f<\/p>\n<p>\u5fae\u670d\u52a1\u8bb8\u8bfa\u4e86\u677e\u8026\u5408\u65f6\u5b9e\u8df5\uff0c\u4f46\u662f\u6211\u4eec\u73b0\u5728\u5df2\u7ecf\u8fc7\u4e86\u4ed6\u4eec\u7684\u7092\u4f5c\u5e74\u4ee3\uff0c\u800c\u96be\u4ee5\u7ef4\u62a4\u7684\u5e94\u7528\u4ecd\u65e7\u5b58\u5728\u3002\u6709\u4e9b\u65f6\u5019\u8fd9\u53cd\u800c\u53d8\u5f97\u66f4\u7cdf\u7cd5\u4e86\uff1a\u6211\u4eec\u843d\u5165\u4e86<a class=\"link\" href=\"https:\/\/threedots.tech\/post\/microservices-or-monolith-its-detail\/\" target=\"_blank\" rel=\"noopener\"\n>\u5206\u5e03\u5f0f\u5355\u4f53<\/a>\u7684\u9677\u9631\uff0c\u5904\u7406\u548c\u4e4b\u524d\u76f8\u540c\u7684\u95ee\u9898\uff0c\u800c\u4e14\u8fd8\u589e\u52a0\u4e86\u7f51\u7edc\u5f00\u9500\u3002<\/p>\n<p><img src=\"https:\/\/threedots.tech\/post\/common-anti-patterns-in-go-web-applications\/microservices.png\"\nloading=\"lazy\"\nalt=\"\u4ece\u5f3a\u8026\u5408\u5355\u4f53\u5e94\u7528\u5230\u5206\u5e03\u5f0f\u5355\u4f53\"\n><\/p>\n<blockquote>\n<p>\u274c \u53cd\u6a21\u5f0f\uff1a\u5206\u5e03\u5f0f\u5355\u4f53 <br>\n\u5728\u4f60\u4e86\u89e3\u8fb9\u754c\u4e4b\u524d\uff0c\u4e0d\u8981\u5c06\u4f60\u7684\u5e94\u7528\u5207\u5206\u6210\u4e3a\u5fae\u670d\u52a1\u3002<\/p><\/blockquote>\n<p>\u5fae\u670d\u52a1\u5e76\u4e0d\u4f1a\u964d\u4f4e\u8026\u5408\uff0c<strong>\u56e0\u4e3a\u62c6\u5206\u670d\u52a1\u7684\u6b21\u6570\u5e76\u4e0d\u91cd\u8981\u3002\u91cd\u8981\u7684\u662f\u5982\u4f55\u8fde\u63a5\u5404\u4e2a\u670d\u52a1<\/strong>\u3002<\/p>\n<p><img src=\"https:\/\/threedots.tech\/post\/common-anti-patterns-in-go-web-applications\/monolith.png\"\nloading=\"lazy\"\nalt=\"\u4ece\u6a21\u5757\u5316\u5355\u4f53\u5e94\u7528\u5230\u677e\u8026\u5408\u5fae\u670d\u52a1\"\n><\/p>\n<blockquote>\n<p>\u2705 \u7b56\u7565\uff1a\u677e\u8026\u5408 <br>\n\u4ee5\u5b9e\u73b0\u677e\u8026\u5408\u7684\u6a21\u5757\u4e3a\u76ee\u6807\u3002\u5982\u4f55\u90e8\u7f72\u5b83\u4eec\uff08\u4f5c\u4e3a\u6a21\u5757\u5316\u5355\u4f53\u5e94\u7528\u6216\u5fae\u670d\u52a1\uff09\u662f\u4e00\u4e2a\u5b9e\u73b0\u7ec6\u8282\u3002<\/p><\/blockquote>\n<h2 id=\"dry\u5f15\u5165\u4e86\u8026\u5408\">DRY\u5f15\u5165\u4e86\u8026\u5408\n<\/h2><p>\u5f3a\u8026\u5408\u5341\u5206\u5e38\u89c1\uff0c\u56e0\u4e3a\u6211\u4eec\u5f88\u65e9\u5c31\u5b66\u5230\u4e86\u4e0d\u8981\u91cd\u590d\u81ea\u5df1(Don&rsquo;t Repeat Yourself, DRY)\u539f\u5219\u3002<\/p>\n<p>\u7b80\u77ed\u7684\u89c4\u5219\u5f88\u5bb9\u6613\u88ab\u5927\u5bb6\u8bb0\u4f4f\uff0c\u4f46\u662f\u7b80\u77ed\u7684\u4e09\u4e2a\u5355\u8bcd\u5f88\u96be\u6982\u62ec\u6240\u6709\u7684\u7ec6\u8282\u3002\u300a\u7a0b\u5e8f\u5458\u4fee\u70bc\u4e4b\u9053: \u4ece\u5c0f\u5de5\u5230\u4e13\u5bb6\u300b\u8fd9\u672c\u4e66\u63d0\u4f9b\u4e86\u4e00\u4e2a\u66f4\u957f\u7684\u7248\u672c\uff1a<\/p>\n<blockquote>\n<p>\u6bcf\u6761\u77e5\u8bc6\u5728\u7cfb\u7edf\u4e2d\u90fd\u5fc5\u987b\u6709\u4e00\u4e2a\u5355\u4e00\u7684\u3001\u660e\u786e\u7684\u3001\u6743\u5a01\u7684\u8868\u8ff0\u3002<\/p><\/blockquote>\n<p>&ldquo;\u6bcf\u4e00\u6761\u77e5\u8bc6&quot;\u8fd9\u4e2a\u8bf4\u6cd5\u76f8\u5f53\u6781\u7aef\u3002\u5927\u591a\u6570\u7f16\u7a0b\u56f0\u5883\u7684\u7b54\u6848\u662f\u770b\u60c5\u51b5\u800c\u5b9a\uff0cDRY\u4e5f\u4e0d\u4f8b\u5916\u3002<\/p>\n<p><strong>\u5f53\u4f60\u8ba9\u4e24\u4e2a\u4e8b\u7269\u4f7f\u7528\u76f8\u540c\u62bd\u8c61\u7684\u65f6\u5019\uff0c\u4f60\u5c31\u5f15\u5165\u4e86\u8026\u5408\u3002\u5982\u679c\u4f60\u4e25\u683c\u9075\u5faaDRY\u539f\u5219\uff0c\u4f60\u5c31\u9700\u8981\u5728\u8fd9\u4e2a\u62bd\u8c61\u4e4b\u524d\u589e\u52a0\u62bd\u8c61\u3002<\/strong><\/p>\n<p><img src=\"https:\/\/threedots.tech\/post\/common-anti-patterns-in-go-web-applications\/coupling.png\"\nloading=\"lazy\"\n><\/p>\n<h2 id=\"\u5728go\u4e2d\u4fdd\u6301dry\">\u5728Go\u4e2d\u4fdd\u6301DRY\n<\/h2><p>\u76f8\u6bd4\u4e8e\u5176\u4ed6\u73b0\u4ee3\u8bed\u8a00\uff0cGo\u662f\u6e05\u6670\u7684\uff0c\u7f3a\u5c11\u5f88\u591a\u7279\u6027\uff0c\u6ca1\u6709\u592a\u591a\u7684\u8bed\u6cd5\u7cd6\u6765\u9690\u85cf\u590d\u6742\u6027\u3002<\/p>\n<p>\u6211\u4eec\u4e60\u60ef\u4e86\u6377\u5f84\uff0c\u6240\u4ee5\u4e00\u5f00\u59cb\u5f88\u96be\u63a5\u53d7Go\u7684\u5197\u957f\u3002\u5c31\u50cf\u6211\u4eec\u5df2\u7ecf\u5f00\u53d1\u51fa\u4e00\u79cd\u53bb\u5bfb\u627e\u4e00\u79cd\u66f4\u52a0\u806a\u660e\u7684\u7f16\u5199\u4ee3\u7801\u7684\u65b9\u5f0f\u7684\u672c\u80fd\u3002<\/p>\n<p>\u6700\u5178\u578b\u7684\u4f8b\u5b50\u5c31\u662f\u9519\u8bef\u5904\u7406\u3002\u5982\u679c\u4f60\u6709\u7f16\u5199Go\u7684\u7ecf\u9a8c\uff0c\u4f60\u4f1a\u89c9\u5f97\u4e0b\u9762\u7684\u4ee3\u7801\u7247\u6bb5\u5f88\u81ea\u7136<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-go\" data-lang=\"go\"><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">if<\/span> <span style=\"color:#a6e22e\">err<\/span> <span style=\"color:#f92672\">!=<\/span> <span style=\"color:#66d9ef\">nil<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#66d9ef\">return<\/span> <span style=\"color:#a6e22e\">err<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><p>\u4f46\u662f\u5bf9\u65b0\u624b\u800c\u8a00\uff0c\u4e00\u904d\u53c8\u4e00\u904d\u7684\u91cd\u590d\u8fd9\u4e09\u884c\u5c31\u662f\u4f3c\u4e4e\u5728\u7834\u574fDRY\u539f\u5219\u3002\u4ed6\u4eec\u7ecf\u5e38\u60f3\u529e\u6cd5\u6765\u89c4\u907f\u8fd9\u79cd\u6837\u677f\u65b9\u6cd5\uff0c\u4f46\u662f\u5374\u6ca1\u6709\u4ec0\u4e48\u597d\u7684\u7ed3\u679c\u3002<\/p>\n<p>\u6700\u7ec8\uff0c\u5927\u5bb6\u90fd\u63a5\u53d7\u4e86Go\u7684\u5de5\u4f5c\u65b9\u5f0f\u3002<strong>\u5b83\u8ba9\u4f60\u91cd\u590d\u4f60\u81ea\u5df1\uff0c\u4e0d\u8fc7\u8fd9\u5e76\u4e0d\u662fDRY\u544a\u8bc9\u4f60\u7684\u4f60\u8981\u907f\u514d\u91cd\u590d\u3002<\/strong><\/p>\n<h2 id=\"\u5355\u4e00\u6570\u636e\u6a21\u578b\u5e26\u6765\u7684\u5e94\u7528\u8026\u5408\">\u5355\u4e00\u6570\u636e\u6a21\u578b\u5e26\u6765\u7684\u5e94\u7528\u8026\u5408\n<\/h2><p><strong>Go\u4e2d\u6709\u4e00\u4e2a\u7279\u6027\u5f15\u5165\u4e86\u5f3a\u8026\u5408\uff0c\u4f46\u4f1a\u8ba9\u4f60\u8ba4\u4e3a\u4f60\u81ea\u5df1\u5728\u9075\u5faaDRY\u539f\u5219\u3002\u8fd9\u5c31\u662f\u5728\u4e00\u4e2a\u7ed3\u6784\u4f53\u4e2d\u4f7f\u7528\u591a\u4e2a\u6807\u7b7e\u3002<\/strong> \u8fd9\u4f3c\u4e4e\u662f\u4e00\u4e2a\u597d\u4e3b\u610f\uff0c\u56e0\u4e3a\u6211\u4eec\u7ecf\u5e38\u5bf9\u4e0d\u540c\u7684\u4e8b\u7269\u4f7f\u7528\u76f8\u4f3c\u7684\u6a21\u578b\u3002<\/p>\n<p>\u8fd9\u91cc\u6709\u4e00\u4e2a\u6d41\u884c\u7684\u65b9\u5f0f\u4fdd\u5b58\u5355\u4e2a<code>User<\/code>\u6a21\u578b\u7684\u65b9\u6cd5\uff1a<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-go\" data-lang=\"go\"><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">type<\/span> <span style=\"color:#a6e22e\">User<\/span> <span style=\"color:#66d9ef\">struct<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">ID<\/span> <span style=\"color:#66d9ef\">int<\/span> <span style=\"color:#e6db74\">`json:&#34;id&#34; gorm:&#34;autoIncrement primaryKey&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">FirstName<\/span> <span style=\"color:#66d9ef\">string<\/span> <span style=\"color:#e6db74\">`json:&#34;first_name&#34; validate:&#34;required_without=LastName&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">LastName<\/span> <span style=\"color:#66d9ef\">string<\/span> <span style=\"color:#e6db74\">`json:&#34;last_name&#34; validate:&#34;required_without=FirstName&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">DisplayName<\/span> <span style=\"color:#66d9ef\">string<\/span> <span style=\"color:#e6db74\">`json:&#34;display_name&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Email<\/span> <span style=\"color:#66d9ef\">string<\/span> <span style=\"color:#e6db74\">`json:&#34;email,omitempty&#34; gorm:&#34;-&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Emails<\/span> []<span style=\"color:#a6e22e\">Email<\/span> <span style=\"color:#e6db74\">`json:&#34;emails&#34; validate:&#34;required,dive&#34; gorm:&#34;constraint:OnDelete:CASCADE&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">PasswordHash<\/span> <span style=\"color:#66d9ef\">string<\/span> <span style=\"color:#e6db74\">`json:&#34;-&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">LastIP<\/span> <span style=\"color:#66d9ef\">string<\/span> <span style=\"color:#e6db74\">`json:&#34;-&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">CreatedAt<\/span> <span style=\"color:#f92672\">*<\/span><span style=\"color:#a6e22e\">time<\/span>.<span style=\"color:#a6e22e\">Time<\/span> <span style=\"color:#e6db74\">`json:&#34;-&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">UpdatedAt<\/span> <span style=\"color:#f92672\">*<\/span><span style=\"color:#a6e22e\">time<\/span>.<span style=\"color:#a6e22e\">Time<\/span> <span style=\"color:#e6db74\">`json:&#34;-&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">type<\/span> <span style=\"color:#a6e22e\">Email<\/span> <span style=\"color:#66d9ef\">struct<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">ID<\/span> <span style=\"color:#66d9ef\">int<\/span> <span style=\"color:#e6db74\">`json:&#34;-&#34; gorm:&#34;primaryKey&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Address<\/span> <span style=\"color:#66d9ef\">string<\/span> <span style=\"color:#e6db74\">`json:&#34;address&#34; validate:&#34;required,email&#34; gorm:&#34;size:256;uniqueIndex&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Primary<\/span> <span style=\"color:#66d9ef\">bool<\/span> <span style=\"color:#e6db74\">`json:&#34;primary&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">UserID<\/span> <span style=\"color:#66d9ef\">int<\/span> <span style=\"color:#e6db74\">`json:&#34;-&#34;`<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><p>\u5b8c\u6574\u4ee3\u7801\uff1a<a class=\"link\" href=\"https:\/\/github.com\/ThreeDotsLabs\/go-web-app-antipatterns\/blob\/ab94d47350756716a7fed42b7ae546c51c11406a\/01-coupling\/01-tightly-coupled\/internal\/user.go#L9\" target=\"_blank\" rel=\"noopener\"\n>github.com\/ThreeDotsLabs\/go-web-app-antipatterns\/01-coupling\/01-tightly-coupled\/internal\/user.go<\/a><\/p>"},{"title":"\u4ec0\u4e48\u662f\u4e8b\u4ef6\u5efa\u6a21Event Modeling?","link":"https:\/\/www.4async.com\/2021\/07\/introducing-event-modeling\/","pubDate":"Tue, 06 Jul 2021 11:41:00 +0000","guid":"https:\/\/www.4async.com\/2021\/07\/introducing-event-modeling\/","description":"<img src=\"https:\/\/www.4async.com\/2021\/07\/introducing-event-modeling\/event-modeling-tutorial.jpg\" alt=\"Featured image of post \u4ec0\u4e48\u662f\u4e8b\u4ef6\u5efa\u6a21Event Modeling?\" \/><h2 id=\"\u57fa\u672c\u6982\u5ff5\">\u57fa\u672c\u6982\u5ff5\n<\/h2><p>\u4e8b\u4ef6\u5efa\u6a21\uff08Event Modeling\uff09\u662f\u4e00\u79cd\u63cf\u8ff0\u7cfb\u7edf\u7684\u65b9\u6cd5\uff0c\u5c55\u793a\u4fe1\u606f\u5982\u4f55\u968f\u65f6\u95f4\u53d8\u5316\u7684\u4f8b\u5b50\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u8fd9\u79cd\u65b9\u5f0f\u7701\u7565\u4e86\u77ac\u606f\u4e07\u53d8\u7684\u7ec6\u8282\uff0c\u800c\u7740\u773c\u4e8e\u5728\u4efb\u4f55\u7279\u5b9a\u7684\u65f6\u95f4\u70b9\u4e0a\u7684\u6301\u4e45\u5316\u5b58\u50a8\u548c\u7528\u6237\u6240\u89c1\u6570\u636e\u7684\u53d8\u5316\u3002\u8fd9\u4e9b\u65f6\u95f4\u8f74\u4e0a\u7684\u4e8b\u4ef6\uff0c\u6784\u6210\u4e86\u5bf9\u7cfb\u7edf\u7684\u63cf\u8ff0\u3002<\/p>\n<p>\u8fd1\u5e74\u6765\uff0c\u5f88\u591a\u7cfb\u7edf\u4f7f\u7528\u4e8b\u4ef6\u901a\u8fc7\u4e8b\u4ef6\u5b58\u50a8\u6570\u636e\u5e93\u6216\u8005\u4f7f\u7528\u7279\u5b9a\u65b9\u5f0f\u4f7f\u7528\u5e38\u89c4\u6570\u636e\u5e93\u6784\u5efa\u4e86\u72b6\u6001\u548c\u4fe1\u606f\u4f20\u64ad\u7684\u6a21\u5757\u3002\u7136\u800c\uff0c\u5927\u591a\u6570\u65b9\u6cd5\u4ecd\u7136\u4f9d\u8d56\u4e8e\u901a\u8fc7SQL\u6570\u636e\u5e93\u3001\u6587\u6863\u6570\u636e\u5e93\u6216\u8005\u5176\u4ed6\u6280\u672f\u5b9e\u73b0\u4e25\u683c\u610f\u4e49\u4e0a\u7684\u5f53\u524d\u65f6\u95f4\u70b9\u4fe1\u606f\u7684\u89c6\u56fe\u3002<\/p>\n<p>\u5bf9\u5f88\u591a\u7cfb\u7edf\u800c\u8a00\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u975e\u5c0f\u578b\u7cfb\u7edf\u800c\u8a00\uff0c\u968f\u7740\u7cfb\u7edf\u590d\u6742\u6027\u7684\u589e\u52a0\uff0c\u53d8\u66f4\u6210\u672c\u5c06\u4f1a\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\u96be\u5ea6\u6307\u6570\u7ea7\u4e0a\u5347\u3002\u4e0e\u73b0\u6709\u7684\u8bbe\u8ba1\u548c\u5efa\u6a21\u65b9\u5f0f\u5bf9\u6bd4\uff0c\u4e8b\u4ef6\u5efa\u6a21\u53ef\u4ee5\u5728\u77ed\u65f6\u95f4\u5185\u521b\u5efa\u4e00\u4e2a\u57fa\u7840\u84dd\u56fe\uff0c\u5c06\u8fd4\u5de5\u5de5\u4f5c\u91cf\u964d\u5230\u6700\u4f4e\u3002<\/p>\n<h3 id=\"\u4ece\u8fc7\u53bb\u8c08\u8d77\">\u4ece\u8fc7\u53bb\u8c08\u8d77\n<\/h3><p>\u8bb2\u6545\u4e8b\u81ea\u53e4\u4ee5\u6765\u5c31\u662f\u4eba\u7c7b\u80fd\u591f\u5c06\u77e5\u8bc6\u4f20\u9012\u7ed9\u540e\u4ee3\u7684\u65b9\u6cd5\uff0c\u5b83\u5728\u5f88\u5927\u7a0b\u5ea6\u4e0a\u4f9d\u8d56\u4e8e\u6211\u4eec\u5982\u4f55\u5b58\u50a8\u8bb0\u5fc6-\u65e0\u8bba\u662f\u903b\u8f91\u7684\u3001\u89c6\u89c9\u7684\u3001\u542c\u89c9\u7684\u8fd8\u662f\u5176\u4ed6\u7684\u3002\u8fd9\u4e00\u70b9\u5f88\u91cd\u8981\uff0c\u56e0\u4e3a\u8fd9\u4e0e\u4fe1\u606f\u7cfb\u7edf\u7684\u6784\u5efa\u65b9\u5f0f\u6709\u76f8\u4f3c\u4e4b\u5904\u3002\n\u7528\u5177\u4f53\u7684\u4f8b\u5b50\u8bf4\u660e\u67d0\u7269\u5e94\u8be5\u5982\u4f55\u5de5\u4f5c\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u65b9\u5f0f\u3002\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u5728\u8f6f\u4ef6\u5f00\u53d1\u7684\u6210\u529f\u5b9e\u8df5\u4e2d\u770b\u5230\uff0c\u5982\u884c\u4e3a\u9a71\u52a8\u5f00\u53d1\u3002\u8fd9\u79cd\u65b9\u5f0f\u5f88\u6709\u6548\uff0c\u56e0\u4e3a\u6211\u4eec\u901a\u8fc7\u6545\u4e8b\u6765\u6c9f\u901a\u66f4\u6709\u6548\u3002\u5c06\u5b83\u548c\u8bb2\u6545\u4e8b\u8054\u7cfb\u5728\u4e00\u8d77\uff0c\u662f\u4e00\u79cd\u4fdd\u6301\u793e\u4f1a\u4fe1\u606f\u7684\u65b9\u5f0f\u3002\u6211\u4eec\u7684\u5927\u8111\u662f\u4e3a\u5b83\u800c\u5efa\u7684\uff0c\u800c\u4e0d\u662f\u4e3a\u6d41\u7a0b\u56fe\u548c\u5176\u4ed6\u683c\u5f0f\u800c\u5efa\u7684\u3002\n\u800c\u4e8b\u4ef6\u5efa\u6a21\u6a21\u578b\u5c31\u662f\u9075\u5faa\u8fd9\u79cd\u8bb2\u6545\u4e8b\u6a21\u5f0f\u800c\u5efa\u7acb\u7684\u4ea7\u54c1\u5efa\u6a21\u65b9\u5f0f\u3002<\/p>\n<h2 id=\"\u4e8b\u4ef6\u5efa\u6a21\u6a21\u5f0f\">\u4e8b\u4ef6\u5efa\u6a21\u6a21\u5f0f\n<\/h2><p><img src=\"https:\/\/eventmodeling.org\/posts\/what-is-event-modeling\/blueprint_large.jpg\"\nloading=\"lazy\"\n><\/p>\n<p>\u65f6\u95f4\u7ebf\u662f\u6700\u597d\u63cf\u8ff0\u6545\u4e8b\u4e3b\u7ebf\u7684\u65b9\u5f0f\uff0c\u5bf9\u6211\u4eec\u7684\u7cfb\u7edf\u800c\u8a00\uff0c\u65f6\u95f4\u7ebf\u4e5f\u662f\u63cf\u8ff0\u6211\u4eec\u7cfb\u7edf\u6838\u5fc3\u90e8\u5206\u6982\u5ff5\u7684\u91cd\u8981\u7ec4\u6210\u90e8\u5206\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728\u4e00\u6761\u65f6\u95f4\u7ebf\u4e0a\uff0c\u7cfb\u7edf\u4ece\u5f00\u59cb\u5230\u7ed3\u675f\uff0c\u5728\u6ca1\u6709\u5206\u652f\u60c5\u51b5\u4e0b\u5e94\u8be5\u505a\u4ec0\u4e48\u65b9\u5f0f\u5c55\u793a\u6211\u4eec\u7cfb\u7edf\u7684\u4e00\u90e8\u5206\u529f\u80fd\u3002\u8fd9\u5c31\u662f\u4e00\u4e2a\u5178\u578b\u7684\u4e8b\u4ef6\u6a21\u578b\u7684\u7ec4\u6210\u3002\u6211\u4eec\u53ef\u4ee5\u7528\u8fd9\u79cd\u65b9\u5f0f\u8ddf\u8e2a\u6240\u6709UI\u754c\u9762\u4e2d\u5b57\u6bb5\u503c\u5982\u4f55\u5b58\u50a8\u548c\u5982\u4f55\u5c55\u793a\u7684\u3002\u6bd4\u5982\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u56fe\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e863\u79cd\u4e0d\u540c\u6a21\u5757\u7684\u5185\u5bb9\u548c\u4f20\u7edf\u7684\u7ebf\u6846\u6a21\u578b\u5c31\u5c55\u793a\u4e86\u6574\u4e2a\u7cfb\u7edf\u7684\u6a21\u578b\u3002\u4f46\u662f\u7b80\u5355\u6027\u662f\u6211\u4eec\u91cd\u8981\u7684\u4e00\u4e2a\u76ee\u6807\uff0c\u56e0\u6b64\u6211\u4eec\u53ea\u4f9d\u8d56\u4e8e4\u79cd\u6a21\u5f0f\u6784\u5efa\u8fd9\u79cd\u6a21\u578b\u56fe\u3002<\/p>\n<h3 id=\"\u4fdd\u6301\u7b80\u5355\u6027\">\u4fdd\u6301\u7b80\u5355\u6027\n<\/h3><p>\u5f53\u6211\u4eec\u60f3\u91c7\u7528\u67d0\u4e9b\u505a\u6cd5\u6216\u6d41\u7a0b\u6765\u5e2e\u52a9\u5f7c\u6b64\u7406\u89e3\u548c\u6c9f\u901a\u65f6\uff0c\u5b83\u4e0e\u4e2a\u4eba\u4e3a\u719f\u7ec3\u638c\u63e1\u8fd9\u4e9b\u65b9\u6cd5\u800c\u8fdb\u884c\u7684\u5b66\u4e60\u91cf\u6210\u53cd\u6bd4\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u5982\u679c\u6211\u4eec\u53ef\u4ee5\u66f4\u5feb\u7684\u638c\u63e1\u4e00\u4e2a\u540d\u53ebX\u7684\u65b9\u6cd5\u65f6\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u66f4\u597d\u7684\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u8fdb\u884c\u77e5\u8bc6\u5206\u4eab\u548c\u4e92\u52a8\uff1b\u53cd\u4e4b\uff0c\u65e0\u8bba\u8fd9\u79cd\u65b9\u6cd5\u591a\u4e48\u597d\uff0c\u6602\u8d35\u7684\u5b66\u4e60\u6210\u672c\u603b\u4f1a\u641e\u7838\u4e00\u5207\u3002<\/p>\n<blockquote>\n<p>\u5f53\u4e00\u672c\u4e66\u662f\u56e2\u961f\u4e2d\u7684\u5fc5\u8bfb\u4e66\u76ee\u65f6\uff0c\u6bcf\u4e2a\u4eba\u90fd\u4f1a\u8bf4\u4ed6\u4eec\u8bfb\u8fc7\uff1b\u4f46\u4e8b\u5b9e\u4e0a\u53ea\u6709\u4e00\u534a\u7684\u4eba\u4f1a\u771f\u6b63\u8bfb\u8fc7\uff1b\u8fd9\u4e9b\u771f\u6b63\u8bfb\u8fc7\u7684\u4eba\u4e2d\u4e00\u534a\u7684\u4eba\u4f1a\u58f0\u79f0\u4ed6\u4eec\u7406\u89e3\u4e86\u8fd9\u672c\u4e66\uff1b\u800c\u8fd9\u4e9b\u58f0\u79f0\u7406\u89e3\u7684\u4eba\u4e2d\u53ea\u6709\u4e00\u534a\u7684\u4eba\u771f\u6b63\u7684\u7406\u89e3\u4e86\u8fd9\u672c\u4e66\uff1b\u800c\u8fd9\u4e9b\u771f\u6b63\u7406\u89e3\u4e86\u8fd9\u672c\u4e66\u7684\u4eba\u53ea\u6709\u4e00\u534a\u7684\u4eba\u80fd\u591f\u4f7f\u7528\u5b83\u3002<\/p><\/blockquote>\n<p>\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u4f7f\u75283\u4e2a\u6a21\u5757\u548c\u57fa\u4e8e2\u4e2a\u60f3\u6cd5\u76844\u79cd\u6a21\u5f0f\u8fdb\u884c\u4e8b\u4ef6\u5efa\u6a21\u3002\u56e0\u4e3a\u8fd9\u53ea\u9700\u8981\u51e0\u5206\u949f\u5c31\u53ef\u4ee5\u5c06\u6240\u6709\u7684\u4e1c\u897f\u5411\u6240\u6709\u4eba\u89e3\u91ca\u6e05\u695a\u3002\u5176\u4ed6\u7684\u5b66\u4e60\u5219\u53ef\u4ee5\u5728\u5b9e\u8df5\u4e2d\u8fdb\u884c\u3002\u5373\u4fbf\u7406\u89e3\u51fa\u73b0\u4e86\u4e0d\u8db3\u548c\u9519\u8bef\uff0c\u4e5f\u53ef\u4ee5\u5f88\u5feb\u5728\u5b9e\u8df5\u4e2d\u5f97\u5230\u7ea0\u6b63\u3002<\/p>\n<h3 id=\"\u4e8b\u4ef6\">\u4e8b\u4ef6\n<\/h3><p>\u5047\u8bbe\u6211\u4eec\u60f3\u4e3a\u8fde\u9501\u9152\u5e97\u8bbe\u8ba1\u4e00\u4e2a\u9152\u5e97\u7f51\u7ad9\uff0c\u8ba9\u6211\u4eec\u7684\u5ba2\u6237\u53ef\u4ee5\u5728\u7ebf\u9884\u8ba2\u623f\u95f4\uff0c\u5e76\u8ba9\u6211\u4eec\u5b89\u6392\u6e05\u6d01\u548c\u4efb\u4f55\u5176\u4ed6\u9152\u5e97\u95ee\u9898\u3002 \u6211\u4eec\u53ef\u4ee5\u663e\u793a\u5728\u8be5\u4e1a\u52a1\u7684\u5e74\u5ea6\u65f6\u95f4\u7ebf\u4e0a\u5b58\u50a8\u4e86\u54ea\u4e9b\u4e8b\u4ef6\u3002 \u6211\u4eec\u53ef\u4ee5\u5047\u88c5\u6211\u4eec\u5df2\u7ecf\u6709\u4e86\u8fd9\u4e2a\u7cfb\u7edf\uff0c\u7136\u540e\u95ee\u81ea\u5df1\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\u5b58\u50a8\u4e86\u54ea\u4e9b\u4e8b\u4ef6\u3002<\/p>\n<h3 id=\"\u7ebf\u6846\u56fe\">\u7ebf\u6846\u56fe\n<\/h3><p>\u8ba9\u6211\u4eec\u770b\u4e00\u4e0b\u5728\u56fe\u7247\u7684\u6700\u4e0a\u9762\u7684\u90e8\u5206\u7684\u7b2c\u4e00\u4e2a\u6a21\u5757\u3002\u4e3a\u4e86\u8ba9\u8bb2\u6545\u4e8b\u8fd9\u4e2a\u4e8b\u60c5\u66f4\u52a0\u53ef\u89c6\u5316\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u9876\u90e8\u663e\u793a\u529f\u80fd\u7684\u7ebf\u6846\u56fe\u6216\u8005\u7f51\u9875\u6a21\u62df\u56fe\u3002\u8fd9\u4e5f\u53ef\u4ee5\u88ab\u5177\u8c61\u5316\u4e3a\u5177\u4f53\u7684\u6cf3\u9053\u56fe\uff0c\u4ee5\u65b9\u4fbf\u4e0d\u540c\u7684\u4eba\uff08\u4e5f\u53ef\u4ee5\u662f\u7cfb\u7edf\uff09\u4e0e\u6211\u4eec\u7684\u7cfb\u7edf\u8fdb\u884c\u4e92\u52a8\u3002\u8fd9\u91cc\u4e00\u4e9b\u81ea\u52a8\u5316\u7684\u5185\u5bb9\u53ef\u4ee5\u7528\u9f7f\u8f6e\u8868\u793a\uff0c\u540c\u65f6\u8bf4\u660e\u7cfb\u7edf\u6b63\u5728\u505a\u4ec0\u4e48\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u975e\u5e38\u5bb9\u6613\u7684\u5c55\u793a\u51fa\u7cfb\u7edf\u9700\u8981\u5b9e\u73b0\u7684\u529f\u80fd\u5217\u8868\uff0c\u6267\u884c\u6d41\u7a0b\u548c\u9879\u76ee\u5b8c\u6210\u6807\u8bb0\u3002\u8fd9\u91cc\u7684\u56fe\u662f\u793a\u4f8b\u4e86\u4e00\u4e2a\u9152\u5e97\u7684\u9884\u8ba2\u3001\u652f\u4ed8\u548c\u901a\u77e5\u7cfb\u7edf\u7684\u8fc7\u7a0b\uff0c\u6211\u4eec\u53ef\u4ee5\u91cd\u70b9\u5173\u6ce8\u4e00\u4e0b\u6240\u6709\u76f8\u5173\u9ad8\u4eae\u663e\u793a\u7684\u5185\u5bb9\u3002<\/p>\n<p><img src=\"https:\/\/eventmodeling.org\/posts\/what-is-event-modeling\/innovate_large.jpg\"\nloading=\"lazy\"\n><\/p>\n<p>\u501f\u52a9\u8fd9\u4e2a\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u548c\u8bbe\u8ba1\u5e08\u4e00\u8d77\u6c9f\u901a\u8bbe\u8ba1\u7cfb\u7edf\uff0c\u5f53\u7136\uff0c\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u5728\u8bbe\u8ba1\u4e2d\uff0c\u4e24\u4e2a\u91cd\u8981\u7684\u5185\u5bb9\u9700\u8981\u6dfb\u52a0\u5230\u6574\u4e2a\u8bbe\u8ba1\u4e2d\uff1a\u7528\u6237\u6240\u62e5\u6709\u7684\u6743\u9650\u548c\u7528\u6237\u53ef\u4ee5\u83b7\u53d6\u7684\u4fe1\u606f\u3002<\/p>\n<h3 id=\"\u547d\u4ee4\">\u547d\u4ee4\n<\/h3><p>\u5927\u591a\u6570\u4fe1\u606f\u7cfb\u7edf\u5fc5\u987b\u7ed9\u7528\u6237\u4e00\u79cd\u5f71\u54cd\u7cfb\u7edf\u7684\u72b6\u6001\u7684\u80fd\u529b\uff0c\u800c\u8fd9\u79cd\u80fd\u529b\u5c31\u662f\u547d\u4ee4\u3002\u5728\u6211\u4eec\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5fc5\u987b\u5141\u8bb8\u623f\u95f4\u9884\u8ba2\u6539\u53d8\u7cfb\u7edf\u72b6\u6001\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u4e0d\u4f1a\u53d1\u751f\u8d85\u989d\u9884\u8ba2\u60c5\u51b5\u3002\u5f53\u90a3\u4e2a\u4eba\u5728\u672a\u6765\u7684\u9884\u8ba2\u65e5\u671f\u5230\u8fbe\u65f6\uff0c\u4ed6\u4eec\u5c31\u6709\u4e00\u4e2a\u4e3a\u4ed6\u4eec\u51c6\u5907\u7684\u623f\u95f4\u3002<\/p>\n<p>\u6539\u53d8\u7cfb\u7edf\u72b6\u6001\u7684\u610f\u56fe\u4f1a\u88ab\u5c01\u88c5\u5728\u4e00\u4e2a\u547d\u4ee4\u4e2d\u3002\u76f8\u5bf9\u4e8e\u7b80\u5355\u5730\u5c06\u8868\u5355\u6570\u636e\u4fdd\u5b58\u5230\u6570\u636e\u5e93\u4e2d\u7684\u4e00\u4e2a\u8868\u4e2d\uff0c\u8fd9\u53ef\u4ee5\u8ba9\u6211\u4eec\u4ee5\u975e\u6280\u672f\u6027\u7684\u65b9\u5f0f\u6765\u663e\u793a\u610f\u56fe\uff0c\u540c\u65f6\u5141\u8bb8\u4efb\u4f55\u5b9e\u73b0 - \u5c3d\u7ba1\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u67d0\u4e9b\u65b9\u6cd5\u66f4\u5177\u4f18\u52bf\u3002<\/p>\n<p><img src=\"https:\/\/eventmodeling.org\/posts\/what-is-event-modeling\/empower_large.jpg\"\nloading=\"lazy\"\n><\/p>\n<p>\u4eceUI\u548cUX\u7684\u89d2\u5ea6\u6765\u770b\uff0c\u8fd9\u5c31\u662f\u4e00\u4e2a&quot;\u547d\u4ee4\u54cd\u5e94\u5f0f\u7528\u6237\u754c\u9762&quot;\uff0c\u5bf9\u5e2e\u52a9\u5236\u4f5c\u53ef\u7ec4\u5408\u7684UI\u5927\u6709\u5e2e\u52a9\u3002\u4f7f\u7528\u8fd9\u79cd\u6a21\u5f0f\uff0c\u4ece\u6280\u672f\u548c\u5546\u4e1a\u7684\u89d2\u5ea6\u6765\u770b\uff0c\u4ea4\u6613\u7684\u754c\u9650\u5c31\u66f4\u6e05\u695a\u4e86\u3002\u4ee5\u9152\u5e97\u5165\u4f4f\u4e3a\u4f8b\uff0c\u9152\u5e97\u7684\u5ba2\u4eba\u8981\u4e48\u767b\u8bb0\u6210\u529f\uff0c\u8981\u4e48\u6ca1\u6709\u3002<\/p>\n<p>\u5f53\u547d\u4ee4\u6210\u529f\u7684\u524d\u63d0\u6761\u4ef6\u6709\u7ec6\u5fae\u7684\u5dee\u522b\u65f6\uff0c\u5b83\u4eec\u4f1a\u5728&quot;Given-When-Then&quot;\u98ce\u683c\u7684\u63cf\u8ff0\u65b9\u5f0f\u4e2d\u8fdb\u884c\u9610\u8ff0\u3002\u8fd9\u79cd\u65b9\u5f0f\u4e5f\u662f\u884c\u4e3a\u6d4b\u8bd5\u6a21\u5f0f\u60ef\u7528\u7684\u63cf\u8ff0\u65b9\u5f0f\uff0c\u4e5f\u662f\u4e00\u79cd\u6210\u529f\u7684\u8bb2\u8ff0\u6545\u4e8b\u7684\u65b9\u5f0f\u3002\u5b9e\u9645\u6267\u884c\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u6709\u51e0\u4e2a\u8fd9\u6837\u7684\u6545\u4e8b\u6765\u8bf4\u660e\u4e00\u4e2a\u547d\u4ee4\u5982\u4f55\u80fd\u6210\u529f\u6267\u884c\u548c\u4e0d\u80fd\u6210\u529f\u6267\u884c\u3002<\/p>\n<p>\u8fd9\u91cc\u6211\u4eec\u53ef\u4ee5\u7528\u4e00\u4e2a\u4f8b\u5b50\u6765\u63cf\u8ff0\u4e00\u4e0b\uff1a<\/p>\n<blockquote>\n<p>Given\uff1a\u6211\u4eec\u5df2\u7ecf\u6ce8\u518c\u5e76\u6dfb\u52a0\u4e86\u4e00\u4e2a\u652f\u4ed8\u65b9\u5f0f<\/p><\/blockquote>\n<blockquote>\n<p>When\uff1a\u6211\u4eec\u8bd5\u56fe\u9884\u8ba2\u4e00\u4e2a\u623f\u95f4<\/p><\/blockquote>\n<blockquote>\n<p>Then\uff1a\u4e00\u4e2a\u623f\u95f4\u88ab\u9884\u8ba2\u4e86<\/p><\/blockquote>\n<p>\u8fd9\u79cd\u63cf\u8ff0\u65b9\u5f0f\u4e5f\u901a\u5e38\u88ab\u53eb\u505a\u201c\u5b89\u6392\u3001\u884c\u52a8\u3001\u65ad\u8a00\u201d\uff0c\u5728UI\/UX\u7684\u4e16\u754c\u4e2d\uff0c\u4e5f\u88ab\u79f0\u4e3a\u201c\u60c5\u666f\u3001\u7edf\u8ba1\u3001\u4ef7\u503c\u201d\u3002\n\u5728\u56fe\u4e2d\u6211\u4eec\u4e5f\u53ef\u4ee5\u53d1\u73b0\uff0c\u6240\u6709\u7684\u547d\u4ee4\u90fd\u662f\u7528\u84dd\u8272\u8fdb\u884c\u6807\u8bb0\u7684\u3002<\/p>\n<h3 id=\"\u89c6\u56fe\u6216\u8005\u53eb\u8bfb\u6a21\u578b\">\u89c6\u56fe\uff08\u6216\u8005\u53eb\u8bfb\u6a21\u578b\uff09\n<\/h3><p>\u4efb\u4f55\u4fe1\u606f\u7cfb\u7edf\u7684\u4e00\u4e2a\u91cd\u8981\u80fd\u529b\u662f\u5c06\u7cfb\u7edf\u4e2d\u4fdd\u5b58\u7684\u72b6\u6001\u544a\u77e5\u7528\u6237\u3002\u6211\u4eec\u7684\u9152\u5e97\u5ba2\u4eba\u9700\u8981\u77e5\u9053\u4ed6\u4eec\u611f\u5174\u8da3\u7684\u67d0\u4e9b\u7c7b\u578b\u7684\u623f\u95f4\u5728\u54ea\u4e00\u5929\u53ef\u4ee5\u5165\u4f4f\u3002\u8fd9\u901a\u5e38\u6709\u5f88\u591a\u79cd\u60c5\u51b5\uff0c\u9700\u8981\u652f\u6301\u4fe1\u606f\u7cfb\u7edf\u7684\u591a\u4e2a\u6a21\u578b\u3002<\/p>\n<p><img src=\"https:\/\/eventmodeling.org\/posts\/what-is-event-modeling\/inform_large.jpg\"\nloading=\"lazy\"\n><\/p>\n<p>\u968f\u7740\u8fd9\u4e9b\u65b0\u4e8b\u4ef6\u7684\u5b58\u50a8\uff0c\u7cfb\u7edf\u4e2d\u7684\u89c6\u56fe\u4e5f\u4f1a\u4e00\u76f4\u53d8\u5316\u3002\u5728\u6211\u4eec\u7684\u9152\u5e97\u7cfb\u7edf\u4e2d\uff0c\u8fd9\u4e2a\u65e5\u5386\u89c6\u56fe\u968f\u7740\u5f71\u54cd\u5e93\u5b58\u7684\u65b0\u4e8b\u4ef6\u7684\u53d1\u751f\u800c\u88ab\u66f4\u65b0\u3002\u5176\u4ed6\u89c6\u56fe\u4e2d\u6e05\u6d01\u56e2\u961f\u53ef\u4ee5\u5728\u5ba2\u6237\u79bb\u5e97\u4e8b\u4ef6\u5b58\u50a8\u540e\u5728\u5176\u4ed6\u89c6\u56fe\u4e2d\u770b\u5230\u623f\u95f4\u5df2\u7ecf\u53ef\u4ee5\u88ab\u6e05\u7406\u4e86\u3002<\/p>\n<p>\u6307\u5b9a\u89c6\u56fe\u7684\u884c\u4e3a\u65b9\u5f0f\u4e0e\u6211\u4eec\u6307\u5b9a\u63a5\u53d7\u547d\u4ee4\u7684\u65b9\u5f0f\u975e\u5e38\u76f8\u4f3c\uff0c\u4f46\u6709\u4e00\u5904\u4e0d\u540c\u3002\u89c6\u56fe\u662f\u88ab\u52a8\u7684\uff0c\u5e76\u4e14\u4e0d\u80fd\u5728\u4e8b\u4ef6\u88ab\u5b58\u50a8\u5230\u7cfb\u7edf\u4e2d\u4e4b\u540e\u64a4\u9500\u4e8b\u4ef6\u3002<\/p>\n<p>\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<blockquote>\n<p>Given\uff1a\u9152\u5e97\u8bbe\u7f6e\u4e8612\u95f4\u6d77\u666f\u623f\uff0c\u6d77\u666f\u623f\u4ece4\u67084\u65e5\u523012\u65e5\u88ab\u9884\u8ba2<\/p><\/blockquote>\n<blockquote>\n<p>Then\uff1a\u65e5\u5386\u4e0a\u5e94\u8be5\u663e\u793a\u96644\u67084\u65e5\u523012\u65e5\u4ee5\u5916\u7684\u6240\u6709\u6d77\u666f\u623f\u7684\u65e5\u671f<\/p><\/blockquote>\n<p>\u4ece\u4e0a\u9762\u56fe\u4e2d\u6211\u4eec\u4e5f\u53ef\u4ee5\u6ce8\u610f\u5230\uff0c\u6240\u6709\u7684\u8bfb\u90fd\u662f\u7528\u7eff\u8272\u8fdb\u884c\u6807\u8bb0\u7684\u3002<\/p>\n<h3 id=\"\u96c6\u6210\">\u96c6\u6210\n<\/h3><p>\u6211\u4eec\u521a\u521a\u4ecb\u7ecd\u4e86\u63cf\u8ff0\u5927\u591a\u6570\u7cfb\u7edf\u6240\u9700\u7684 4 \u79cd\u6a21\u5f0f\u4e2d\u7684\u524d 2 \u79cd\u6a21\u5f0f\u3002 \u7cfb\u7edf\u53ef\u4ee5\u4ece\u5176\u4ed6\u7cfb\u7edf\u83b7\u53d6\u4fe1\u606f\u5e76\u4e14\u5c06\u4fe1\u606f\u53d1\u9001\u5230\u5176\u4ed6\u7cfb\u7edf\u3002 \u5f3a\u8feb\u8fd9 2 \u4e2a\u6a21\u5f0f\u6210\u4e3a\u524d 2 \u4e2a\u6a21\u5f0f\u7684\u6269\u5c55\u5e76\u5171\u4eab\u76f8\u540c\u7684\u7a7a\u95f4\u662f\u5f88\u8bf1\u4eba\u7684\u9009\u62e9\u3002 \u7136\u800c\u8fd9\u4f1a\u8ba9\u4ea4\u6d41\u53d8\u5f97\u66f4\u52a0\u56f0\u96be\uff0c\u56e0\u4e3a\u5b83\u4eec\u6ca1\u6709\u4eba\u7c7b\u53ef\u89c1\u7684\u65b9\u9762\uff0c\u5e76\u4e14\u9700\u8981\u4e00\u4e9b\u66f4\u9ad8\u7ea7\u522b\u7684\u6a21\u5f0f\u3002<\/p>\n<h3 id=\"\u7ffb\u8bd1\">\u7ffb\u8bd1\n<\/h3><p>\u5f53\u6211\u4eec\u6709\u4e00\u4e2a\u4e3a\u6211\u4eec\u63d0\u4f9b\u4fe1\u606f\u7684\u5916\u90e8\u7cfb\u7edf\u65f6\uff0c\u5c06\u8fd9\u4e9b\u4fe1\u606f\u8f6c\u6362\u6210\u6211\u4eec\u81ea\u5df1\u7cfb\u7edf\u4e2d\u7684\u66f4\u719f\u6089\u7684\u5f62\u5f0f\u4f1a\u5f88\u6709\u5e2e\u52a9\u3002 \u5728\u6211\u4eec\u7684\u9152\u5e97\u7cfb\u7edf\u4e2d\uff0c\u5982\u679c\u9009\u62e9\u8ba9\u6211\u4eec\u7684\u6e05\u6d01\u4eba\u5458\u53cd\u5e94\u66f4\u52a0\u7075\u654f\uff0c\u6211\u4eec\u53ef\u4ee5\u4ece\u5ba2\u4eba\u7684 GPS \u5750\u6807\u4e2d\u83b7\u53d6\u4e8b\u4ef6\u3002 \u6211\u4eec\u4e0d\u60f3\u4f7f\u7528\u7ecf\u5ea6\u548c\u7eac\u5ea6\u5bf9\u4f5c\u4e3a\u4e8b\u4ef6\u6765\u6307\u5b9a\u6211\u4eec\u7cfb\u7edf\u4e2d\u7684\u5148\u51b3\u6761\u4ef6\u3002 \u6211\u4eec\u5b81\u613f\u9009\u62e9\u5bf9\u6211\u4eec\u6709\u610f\u4e49\u7684\u6d3b\u52a8\uff0c\u4f8b\u5982\u201c\u5ba2\u4eba\u79bb\u5f00\u9152\u5e97\u201d\u3001\u201c\u5ba2\u4eba\u56de\u5230\u9152\u5e97\u623f\u95f4\u201d\u3002<\/p>"},{"title":"\u6784\u5efa\u5c5e\u4e8e\u4f60\u81ea\u5df1\u7684dapr\u7ed1\u5b9a\u7ec4\u4ef6","link":"https:\/\/www.4async.com\/2021\/05\/building-your-own-dapr-binding\/","pubDate":"Sat, 15 May 2021 18:38:00 +0000","guid":"https:\/\/www.4async.com\/2021\/05\/building-your-own-dapr-binding\/","description":"<img src=\"https:\/\/vip1.loli.io\/2022\/03\/26\/uJdVWNeXC6Z3Hq8.png\" alt=\"Featured image of post \u6784\u5efa\u5c5e\u4e8e\u4f60\u81ea\u5df1\u7684dapr\u7ed1\u5b9a\u7ec4\u4ef6\" \/><p>\u5728<a class=\"link\" href=\".\/2021\/05\/2021-05-08-building-your-own-dapr-service-discovery\" >\u4e0a\u4e00\u7bc7\u6587\u7ae0<\/a>\u4e2d\uff0c\u5410\u69fd\u4e86\u62d6\u5ef6\u75c7\u7684\u5371\u5bb3\uff0c\u56e0\u6b64\u8fd9\u6b21\u6211\u6765\u5206\u4eab\u4e00\u4e0b\u6211\u6700\u65b0\u63a8\u9001\u5230dapr\u7684\u6700\u65b0\u7684\u4e00\u4e2a\u65b0\u7684\u7ed1\u5b9a\u7ec4\u4ef6\uff0c\u901a\u8fc7\u8fd9\u4e2a\u6765\u770b\u4e00\u4e0b\u5982\u4f55\u5b9e\u73b0\u81ea\u5df1\u7684\u7ed1\u5b9a\u7ec4\u4ef6\u3002<\/p>\n<p>\u6587\u4e2d\u63d0\u5230\u7684PR\u53ef\u4ee5\u5728 <a class=\"link\" href=\"https:\/\/github.com\/dapr\/components-contrib\/pull\/872\" target=\"_blank\" rel=\"noopener\"\n>dapr\/components-contrib#872<\/a> \u67e5\u770b\u5bf9\u5e94\u7684\u5177\u4f53\u4ee3\u7801\u3002<\/p>\n<h2 id=\"\u4ec0\u4e48\u662f-dapr-\u7684\u7ed1\u5b9a\u7ec4\u4ef6\">\u4ec0\u4e48\u662f dapr \u7684\u7ed1\u5b9a\u7ec4\u4ef6\uff1f\n<\/h2><p>\u5728dapr\u4e2d\uff0c\u7ed1\u5b9a\u662f\u7528\u4e8e\u4f7f\u7528\u5916\u90e8\u7cfb\u7edf\u529f\u80fd\uff08\u6bd4\u5982\u4e8b\u4ef6\u6216\u8005\u63a5\u53e3\uff09\u7684\u6269\u5c55\u7ec4\u4ef6\u3002\u5b83\u7684\u4f18\u52bf\u5728\u4e8e\uff1a<\/p>\n<ul>\n<li>\u514d\u9664\u8fde\u63a5\u5230\u6d88\u606f\u4f20\u9012\u7cfb\u7edf(\u5982\u961f\u5217\u548c\u6d88\u606f\u603b\u7ebf)\u5e76\u8fdb\u884c\u8f6e\u8be2\u7684\u590d\u6742\u6027\uff1b<\/li>\n<li>\u805a\u7126\u4e8e\u4e1a\u52a1\u903b\u8f91\uff0c\u800c\u4e0d\u662f\u5982\u4f55\u4e0e\u7cfb\u7edf\u4ea4\u4e92\u7684\u5b9e\u73b0\u7ec6\u8282\uff1b<\/li>\n<li>\u4f7f\u4ee3\u7801\u4e0d\u53d7 SDK \u6216\u5e93\u7684\u8ddf\u8e2a\uff1b<\/li>\n<li>\u5904\u7406\u91cd\u8bd5\u548c\u6545\u969c\u6062\u590d\uff1b<\/li>\n<li>\u5728\u8fd0\u884c\u65f6\u5728\u7ed1\u5b9a\u4e4b\u95f4\u5207\u6362\uff1b<\/li>\n<li>\u6784\u5efa\u5177\u6709\u7279\u5b9a\u4e8e\u73af\u5883\u7684\u7ed1\u5b9a\u7684\u53ef\u79fb\u690d\u5e94\u7528\u7a0b\u5e8f\uff0c\u4e0d\u9700\u8981\u8fdb\u884c\u4ee3\u7801\u66f4\u6539\uff1b<\/li>\n<\/ul>\n<p>\u5728\u5b98\u65b9\u6587\u6863\u4e2d\uff0c\u4e5f\u63d0\u5230\u4e86\u4e00\u4e2a\u5177\u4f53\u7684\u4f8b\u5b50\uff1a\u4ee5twilio\u53d1\u9001\u77ed\u4fe1\u4e3a\u4f8b\uff0c\u4e00\u822c\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u4f9d\u8d56Twilio SDK\u624d\u53ef\u4ee5\u5b9e\u73b0\u529f\u80fd\uff0c\u4f46\u662f\u501f\u52a9\u7ed1\u5b9a\u7ec4\u4ef6\uff0c\u4f60\u53ef\u4ee5\u5c06SDK\u7684\u7ed1\u5b9a\u8f6c\u79fb\u81f3dapr\u7a0b\u5e8f\u9886\u57df\u5185\uff0c\u5728\u672c\u8eab\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4e0d\u518d\u7ed1\u5b9a\u5bf9\u5e94\u7684SDK\uff0c\u4e0d\u7528\u62c5\u5fc3\u672a\u6765SDK\u8fc7\u671f\u6216\u8005\u53d8\u66f4\u5e26\u6765\u7684\u91cd\u590d\u5de5\u4f5c\uff08\u4ec5\u9700\u8981\u66f4\u65b0dapr\u5373\u53ef\uff09\u3002<\/p>\n<p>\u6839\u636e\u8ba2\u9605\u7684\u8fdb\u51fa\u65b9\u5411\uff0c\u7ed1\u5b9a\u7ec4\u4ef6\u4e5f\u5206\u4e3a\u8f93\u5165\u7ed1\u5b9a\u548c\u8f93\u51fa\u7ed1\u5b9a\u3002\u8fd9\u4e9b\u7ed1\u5b9a\u5747\u662f\u901a\u8fc7yaml\u6587\u4ef6\u63cf\u8ff0\u7c7b\u578b\u548c\u5143\u6570\u636e\uff0c\u901a\u8fc7HTTP\/gRPC\u8fdb\u884c\u8c03\u7528\u3002<\/p>\n<h2 id=\"\u5982\u4f55\u5b9e\u73b0\u81ea\u5df1\u7684\u7ed1\u5b9a\u7ec4\u4ef6\">\u5982\u4f55\u5b9e\u73b0\u81ea\u5df1\u7684\u7ed1\u5b9a\u7ec4\u4ef6\uff1f\n<\/h2><p>\u5b98\u65b9\u4f8b\u5b50\u4e2d\u63d0\u4f9b\u4e86\u4e00\u4e2a\u57fa\u7840\u7684\u4ecb\u7ecd\uff0c\u4e0a\u4e00\u8282\u4e2d\u6211\u4eec\u4e5f\u63d0\u5230\u4e86\u5728\u7a0b\u5e8f\u4e2d\uff0c\u6839\u636e\u8fdb\u51fa\u65b9\u5411\u53ef\u4ee5\u628a\u7ed1\u5b9a\u7ec4\u4ef6\u5206\u4e3a\u8f93\u51fa\u7ed1\u5b9a\u548c\u8f93\u5165\u7ed1\u5b9a\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u5b98\u65b9\u6559\u7a0b\u4e2d\u7684\u4f8b\u5b50\u63d0\u4f9b\u67e5\u770b\uff1a<\/p>\n<p><img src=\"https:\/\/raw.githubusercontent.com\/dapr\/quickstarts\/master\/bindings\/img\/Bindings_Standalone.png\"\nloading=\"lazy\"\n><\/p>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u7528\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\uff0c\u6839\u636e\u65b9\u5411\u5427dapr\u53d1\u5e03\u6d88\u606f\u5230Kafka\u4f5c\u4e3a\u8f93\u51fa\u7ec4\u4ef6\uff0c\u628aKafka\u8bfb\u53d6\u6d88\u606f\u5230dapr\u4f5c\u4e3a\u8f93\u5165\u7ec4\u4ef6\u3002<\/p>\n<p>\u7ed1\u5b9a\u7684\u58f0\u660eyaml\u6587\u4ef6\u7684\u89c4\u8303\u5219\u5982\u4e0b\uff1a<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-yaml\" data-lang=\"yaml\"><span style=\"display:flex;\"><span><span style=\"color:#f92672\">apiVersion<\/span>: <span style=\"color:#ae81ff\">dapr.io\/v1alpha1<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#f92672\">kind<\/span>: <span style=\"color:#ae81ff\">Component<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#f92672\">metadata<\/span>:\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#f92672\">name<\/span>: <span style=\"color:#ae81ff\">&lt;NAME&gt;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#f92672\">namespace<\/span>: <span style=\"color:#ae81ff\">&lt;NAMESPACE&gt;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#f92672\">spec<\/span>:\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#f92672\">type<\/span>: <span style=\"color:#ae81ff\">bindings.&lt;TYPE&gt;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#f92672\">version<\/span>: <span style=\"color:#ae81ff\">v1<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#f92672\">metadata<\/span>:\n<\/span><\/span><span style=\"display:flex;\"><span> - <span style=\"color:#f92672\">name<\/span>: <span style=\"color:#ae81ff\">&lt;NAME&gt;<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#f92672\">value<\/span>: <span style=\"color:#ae81ff\">&lt;VALUE&gt;<\/span>\n<\/span><\/span><\/code><\/pre><\/div><p>\u5176\u4e2d<code>metadata.name<\/code>\u5219\u662f\u7ed1\u5b9a\u7f6e\u540d\u79f0\uff0c<code>spec.metadata.name<\/code>\u548c<code>spec.metadata.value<\/code>\u5219\u662f\u914d\u7f6e\u7684\u5c5e\u6027\u548c\u5bf9\u5e94\u503c\u3002\u8fd9\u4e2a\u503c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5b9e\u73b0\u63a5\u53e3<code>InputBinding<\/code>\u6216\u8005<code>OutputBinding<\/code>\u5b9e\u73b0\u8f93\u5165\u7ed1\u5b9a\u548c\u8f93\u51fa\u7ed1\u5b9a.<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-go\" data-lang=\"go\"><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">type<\/span> <span style=\"color:#a6e22e\">InputBinding<\/span> <span style=\"color:#66d9ef\">interface<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Init<\/span>(<span style=\"color:#a6e22e\">metadata<\/span> <span style=\"color:#a6e22e\">Metadata<\/span>) <span style=\"color:#66d9ef\">error<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Read<\/span>(<span style=\"color:#a6e22e\">handler<\/span> <span style=\"color:#66d9ef\">func<\/span>(<span style=\"color:#f92672\">*<\/span><span style=\"color:#a6e22e\">ReadResponse<\/span>) ([]<span style=\"color:#66d9ef\">byte<\/span>, <span style=\"color:#66d9ef\">error<\/span>)) <span style=\"color:#66d9ef\">error<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">type<\/span> <span style=\"color:#a6e22e\">OutputBinding<\/span> <span style=\"color:#66d9ef\">interface<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Init<\/span>(<span style=\"color:#a6e22e\">metadata<\/span> <span style=\"color:#a6e22e\">Metadata<\/span>) <span style=\"color:#66d9ef\">error<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Invoke<\/span>(<span style=\"color:#a6e22e\">req<\/span> <span style=\"color:#f92672\">*<\/span><span style=\"color:#a6e22e\">InvokeRequest<\/span>) (<span style=\"color:#f92672\">*<\/span><span style=\"color:#a6e22e\">InvokeResponse<\/span>, <span style=\"color:#66d9ef\">error<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Operations<\/span>() []<span style=\"color:#a6e22e\">OperationKind<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><p>\u63a5\u4e0b\u6765\u9700\u8981\u5b9e\u73b0\u4e00\u4e2a\u751f\u6210\u5bf9\u8c61\u7684\u65b9\u6cd5\uff0c\u6bd4\u5982\u8bf4\u6211\u4eec\u9700\u8981\u5b9e\u73b0\u4e00\u4e2a\u98de\u4e66\u63a8\u9001Webhook\u7684\u7ed1\u5b9a\u7ec4\u4ef6\uff0c\u5219\u53ef\u4ee5\uff1a<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-go\" data-lang=\"go\"><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">type<\/span> <span style=\"color:#a6e22e\">FeishuWebhook<\/span> <span style=\"color:#66d9ef\">struct<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">logger<\/span> <span style=\"color:#a6e22e\">logger<\/span>.<span style=\"color:#a6e22e\">Logger<\/span> <span style=\"color:#75715e\">\/\/ \u8fd9\u4e2a\u662fdapr\u7684\u65e5\u5fd7\u63a5\u53e3\uff0c\u8f93\u51fa\u65e5\u5fd7\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">settings<\/span> <span style=\"color:#a6e22e\">Settings<\/span> <span style=\"color:#75715e\">\/\/ \u5177\u4f53\u914d\u7f6e\u4fe1\u606f<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">httpClient<\/span> <span style=\"color:#f92672\">*<\/span><span style=\"color:#a6e22e\">http<\/span>.<span style=\"color:#a6e22e\">Client<\/span> <span style=\"color:#75715e\">\/\/ \u8bf7\u6c42HTTP<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">func<\/span> <span style=\"color:#a6e22e\">NewFeishuWebhook<\/span>(<span style=\"color:#a6e22e\">l<\/span> <span style=\"color:#a6e22e\">logger<\/span>.<span style=\"color:#a6e22e\">Logger<\/span>) <span style=\"color:#f92672\">*<\/span><span style=\"color:#a6e22e\">FeishuWebhook<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#75715e\">\/\/ See guidance on proper HTTP client settings here:<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#75715e\">\/\/ https:\/\/medium.com\/@nate510\/don-t-use-go-s-default-http-client-4804cb19f779<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">dialer<\/span> <span style=\"color:#f92672\">:=<\/span> <span style=\"color:#f92672\">&amp;<\/span><span style=\"color:#a6e22e\">net<\/span>.<span style=\"color:#a6e22e\">Dialer<\/span>{ <span style=\"color:#75715e\">\/\/nolint:exhaustivestruct<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Timeout<\/span>: <span style=\"color:#ae81ff\">5<\/span> <span style=\"color:#f92672\">*<\/span> <span style=\"color:#a6e22e\">time<\/span>.<span style=\"color:#a6e22e\">Second<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#66d9ef\">var<\/span> <span style=\"color:#a6e22e\">netTransport<\/span> = <span style=\"color:#f92672\">&amp;<\/span><span style=\"color:#a6e22e\">http<\/span>.<span style=\"color:#a6e22e\">Transport<\/span>{ <span style=\"color:#75715e\">\/\/nolint:exhaustivestruct<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">DialContext<\/span>: <span style=\"color:#a6e22e\">dialer<\/span>.<span style=\"color:#a6e22e\">DialContext<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">TLSHandshakeTimeout<\/span>: <span style=\"color:#ae81ff\">5<\/span> <span style=\"color:#f92672\">*<\/span> <span style=\"color:#a6e22e\">time<\/span>.<span style=\"color:#a6e22e\">Second<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">httpClient<\/span> <span style=\"color:#f92672\">:=<\/span> <span style=\"color:#f92672\">&amp;<\/span><span style=\"color:#a6e22e\">http<\/span>.<span style=\"color:#a6e22e\">Client<\/span>{ <span style=\"color:#75715e\">\/\/nolint:exhaustivestruct<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Timeout<\/span>: <span style=\"color:#a6e22e\">defaultHTTPClientTimeout<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Transport<\/span>: <span style=\"color:#a6e22e\">netTransport<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#66d9ef\">return<\/span> <span style=\"color:#f92672\">&amp;<\/span><span style=\"color:#a6e22e\">FeishuWebhook<\/span>{ <span style=\"color:#75715e\">\/\/nolint:exhaustivestruct<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">logger<\/span>: <span style=\"color:#a6e22e\">l<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">httpClient<\/span>: <span style=\"color:#a6e22e\">httpClient<\/span>,\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><p>\u5728\u7ed1\u5b9a\u7ec4\u4ef6\u751f\u547d\u5468\u671f\u4e2d\uff0cinit\u4f1a\u5728\u521d\u59cb\u5316\u662f\u8fdb\u884c\u8c03\u7528\uff0c\u4f20\u5165\u6211\u4eec\u4e4b\u524d\u5728yaml\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u5728\u8fd9\u91cc\u5b9e\u73b0\u5177\u4f53\u7684\u914d\u7f6e\u83b7\u53d6\uff1a<\/p>"},{"title":"\u6784\u5efa\u5c5e\u4e8e\u4f60\u81ea\u5df1\u7684dapr\u670d\u52a1\u53d1\u73b0","link":"https:\/\/www.4async.com\/2021\/05\/building-your-own-dapr-service-discovery\/","pubDate":"Sat, 08 May 2021 18:38:00 +0000","guid":"https:\/\/www.4async.com\/2021\/05\/building-your-own-dapr-service-discovery\/","description":"<img src=\"https:\/\/vip1.loli.io\/2022\/03\/26\/uJdVWNeXC6Z3Hq8.png\" alt=\"Featured image of post \u6784\u5efa\u5c5e\u4e8e\u4f60\u81ea\u5df1\u7684dapr\u670d\u52a1\u53d1\u73b0\" \/><p><strong>\u5199\u5728\u6700\u524d: \u8fd9\u7bc7\u6587\u7ae0\u5176\u5b9e\u7b97\u662f\u9a6c\u540e\u70ae\u4e86\uff0c\u56e0\u4e3a\u4e00\u76f4\u62d6\u5ef6\u75c7\u7684\u95ee\u9898\uff0c\u987a\u5e26\u8fc7\u4e86\u4e00\u4e2a\u4e94\u4e00\u5047\u671f\uff0c\u7ed3\u679c\u53d1\u73b0\u5df2\u7ecf\u6709\u793e\u533a\u8d21\u732e\u8005\u63d0\u4f9b\u4e86Consul\u7684\u670d\u52a1\u53d1\u73b0\u5b9e\u73b0\uff0c\u4e8e\u662f\u672c\u6765\u5199\u4e86\u4e00\u534a\u7684\u6587\u7ae0\u53ea\u80fd\u8fdb\u884c\u8c03\u6574\u4e86\u3002\u62d6\u5ef6\u75c7\u5bb3\u4eba\u554a\uff01\u51e0\u4e2a\u8349\u7a3f\u7684\u6587\u7ae0\u770b\u6765\u8981\u5c3d\u5feb\u8d76\u51fa\u6765\u4e86\ud83e\udd26\u200d\u2642\ufe0f<\/strong><\/p>\n<p>\u5728<a class=\"link\" href=\".\/2021\/03\/2021-03-11-running-dapr-without-container\/\" >\u4e0a\u4e00\u7bc7\u6587\u7ae0<\/a>\u4e2d\uff0c\u6211\u5176\u5b9e\u9057\u7559\u4e86\u4e00\u4e2a\u95ee\u9898\uff1a\u5982\u4f55\u5b9a\u4e49dapr\u7684\u670d\u52a1\u53d1\u73b0\u5462\uff1f\u5176\u5b9e\u5728\u540e\u9762\u9605\u8bfbdapr\u7684\u6e90\u7801\u4e4b\u540e\u4e5f\u524d\u4e00\u7bc7\u6587\u7ae0\u7684\u8bc4\u8bba\u4e2d\u63d0\u5230\u4e86\u7b54\u6848\uff1a\u76ee\u524ddapr\u63d0\u4f9b\u4e86\u5185\u7f6e\u4e24\u79cd\u670d\u52a1\u53d1\u73b0\u6a21\u5f0f\uff1aK8s\u6a21\u5f0f\u548c\u7528\u4e8e\u72ec\u7acb\u90e8\u7f72\u7684mDNS\u6a21\u5f0f\u3002mDNS\u6a21\u5f0f\u5728\u67d0\u4e9b\u7f51\u7edc\u73af\u5883\u4e0b\u53ef\u80fd\u5b58\u5728\u95ee\u9898\uff08\u6bd4\u5982\u8de8\u673a\u623f\uff09\uff0c\u4e0d\u8fc7\u6ca1\u6709\u5173\u7cfb\uff0cdapr\u540c\u65f6\u63d0\u4f9b\u4e86\u53ef\u6269\u5c55\u80fd\u529b\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u81ea\u4e3b\u7684\u670d\u52a1\u53d1\u73b0\u80fd\u529b\u6269\u5c55dapr\u7684\u8fb9\u754c\u3002<\/p>\n<h2 id=\"\u4ece-nameresolution-\u5230-resolver-\u63a5\u53e3\">\u4ece NameResolution \u5230 Resolver \u63a5\u53e3\n<\/h2><p>\u5728 <a class=\"link\" href=\"https:\/\/github.com\/dapr\/dapr\/blob\/9341e3faa67ede470febe987b3398775759cf38f\/pkg\/components\/nameresolution\/registry.go#L25\" target=\"_blank\" rel=\"noopener\"\n><code>pkg\/components\/nameresolution\/registry.go<\/code><\/a> \u6587\u4ef6\u4e2d\uff0cdapr\u5b9a\u4e49\u4e86\u4e00\u4e2a <code>NameResolution<\/code> \u7ed3\u6784\u4f53\u7528\u4e8e\u670d\u52a1\u6ce8\u518c\u548c\u53d1\u73b0\uff1a<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-go\" data-lang=\"go\"><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">type<\/span> (\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#75715e\">\/\/ NameResolution is a name resolution component definition.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">NameResolution<\/span> <span style=\"color:#66d9ef\">struct<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Name<\/span> <span style=\"color:#66d9ef\">string<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">FactoryMethod<\/span> <span style=\"color:#66d9ef\">func<\/span>() <span style=\"color:#a6e22e\">nr<\/span>.<span style=\"color:#a6e22e\">Resolver<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#75715e\">\/\/ Registry handles registering and creating name resolution components.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Registry<\/span> <span style=\"color:#66d9ef\">interface<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Register<\/span>(<span style=\"color:#a6e22e\">components<\/span> <span style=\"color:#f92672\">...<\/span><span style=\"color:#a6e22e\">NameResolution<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Create<\/span>(<span style=\"color:#a6e22e\">name<\/span>, <span style=\"color:#a6e22e\">version<\/span> <span style=\"color:#66d9ef\">string<\/span>) (<span style=\"color:#a6e22e\">nr<\/span>.<span style=\"color:#a6e22e\">Resolver<\/span>, <span style=\"color:#66d9ef\">error<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">nameResolutionRegistry<\/span> <span style=\"color:#66d9ef\">struct<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">resolvers<\/span> <span style=\"color:#66d9ef\">map<\/span>[<span style=\"color:#66d9ef\">string<\/span>]<span style=\"color:#66d9ef\">func<\/span>() <span style=\"color:#a6e22e\">nr<\/span>.<span style=\"color:#a6e22e\">Resolver<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> }\n<\/span><\/span><span style=\"display:flex;\"><span>)\n<\/span><\/span><\/code><\/pre><\/div><p>\u5176\u4e2d\u771f\u6b63\u7684\u670d\u52a1\u89e3\u6790\u5219\u662f\u4f9d\u9760 <a class=\"link\" href=\"https:\/\/github.com\/dapr\/components-contrib\/blob\/3ef025c604952ad78101ecb52afe1c7c92c7d455\/nameresolution\/nameresolution.go#L9\" target=\"_blank\" rel=\"noopener\"\n><code>components-contrib<\/code><\/a> \u4e2d\u5b9e\u73b0\u4e86 <code>Resolver<\/code> \u63a5\u53e3\u7684\u5177\u4f53\u5b9e\u73b0\u6267\u884c\u3002<\/p>\n<div class=\"highlight\"><pre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;\"><code class=\"language-go\" data-lang=\"go\"><span style=\"display:flex;\"><span><span style=\"color:#75715e\">\/\/ Resolver is the interface of name resolver.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span><span style=\"color:#66d9ef\">type<\/span> <span style=\"color:#a6e22e\">Resolver<\/span> <span style=\"color:#66d9ef\">interface<\/span> {\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#75715e\">\/\/ Init initializes name resolver.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">Init<\/span>(<span style=\"color:#a6e22e\">metadata<\/span> <span style=\"color:#a6e22e\">Metadata<\/span>) <span style=\"color:#66d9ef\">error<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#75715e\">\/\/ ResolveID resolves name to address.<\/span>\n<\/span><\/span><span style=\"display:flex;\"><span> <span style=\"color:#a6e22e\">ResolveID<\/span>(<span style=\"color:#a6e22e\">req<\/span> <span style=\"color:#a6e22e\">ResolveRequest<\/span>) (<span style=\"color:#66d9ef\">string<\/span>, <span style=\"color:#66d9ef\">error<\/span>)\n<\/span><\/span><span style=\"display:flex;\"><span>}\n<\/span><\/span><\/code><\/pre><\/div><p>\u5176\u4e2d <code>Init<\/code> \u4f1a\u5728 Runtime \u521d\u59cb\u5316\u65f6\u88ab\u8c03\u7528\uff0c\u800c <code>ResolveID<\/code> \u5219\u4f1a\u5728\u670d\u52a1\u67e5\u8be2\u65f6\u8c03\u7528\u3002\u6bd4\u5982\u5728 <a class=\"link\" href=\"https:\/\/github.com\/dapr\/dapr\/blob\/1cbf67f8a5da0bb5be4e3a123632c17ebb173f4e\/pkg\/messaging\/direct_messaging.go#L219\" target=\"_blank\" rel=\"noopener\"\n><code>pkg\/messaging\/direct_messaging.go<\/code><\/a> \u7684\u65b9\u6cd5 <code>getRemoteApp<\/code> \u4e2d\u8fdb\u884c\u670d\u52a1\u7684\u89e3\u6790\uff1a<\/p>"}]}}