<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Reader on 小惡魔 - AppleBOY</title><link>https://blog.wu-boy.com/tags/reader/</link><description>Recent content in Reader on 小惡魔 - AppleBOY</description><generator>Hugo</generator><language>en-us</language><managingEditor>appleboy.tw@gmail.com (Appleboy)</managingEditor><webMaster>appleboy.tw@gmail.com (Appleboy)</webMaster><lastBuildDate>Fri, 21 May 2021 04:52:17 +0000</lastBuildDate><atom:link href="https://blog.wu-boy.com/tags/reader/feed.xml" rel="self" type="application/rss+xml"/><item><title>如何取得上傳進度條 progress bar 相關數據及實作 Graceful Shutdown</title><link>https://blog.wu-boy.com/2021/05/graceful-shutdown-with-progress-bar-in-golang/</link><pubDate>Fri, 21 May 2021 04:52:17 +0000</pubDate><author>appleboy.tw@gmail.com (Appleboy)</author><guid>https://blog.wu-boy.com/2021/05/graceful-shutdown-with-progress-bar-in-golang/</guid><description>&lt;p&gt;&lt;img src="https://lh3.googleusercontent.com/ASkclquxfpPTlJ_QWnhZjB5katrz18NyK4zt2w47UM8gS71MCjWodDoGp50nHRyeQx8MfbJJbwWjfIWCoKbZYLkec7a-FqMEw-r9Lh3U8XGAuwEqWa3DVMB2lkhdgMQUI1IMiKWL5Ss=w1920-h1080" alt=""&gt;&lt;/p&gt;
&lt;p&gt;由於專案需求，需要開發一套 CLI 工具，讓 User 可以透過 CLI 上傳大檔案來進行 Model Training，請參考上面的流程圖。首先第一步驟會先跟 API Server 驗證使用者，驗證完畢就開始上傳資料到 &lt;a href="https://aws.amazon.com/tw/s3/"&gt;AWS S3&lt;/a&gt; 或其他 Storage 空間，除了上傳過程需要在 CLI 顯示目前進度，另外也需要將目前上傳的進度 (速度, 進度及剩餘時間) 都上傳到 API Server，最後在 Web UI 介面透過 &lt;a href="https://www.apollographql.com/docs/react/data/subscriptions/"&gt;GraphQL Subscription&lt;/a&gt; 讓使用者可以即時看到上傳進度數據。&lt;/p&gt;
&lt;p&gt;而 CLI 上傳進度部分，我們選用了一套開源套件 &lt;a href="https://github.com/cheggaaa/pb"&gt;cheggaaa/pb&lt;/a&gt;，相信有在寫 &lt;a href="https://golang.org"&gt;Go 語言&lt;/a&gt;都並不會陌生。而此套件雖然可以幫助在 Terminal 顯示進度條，但是有些接口是沒有提供的，像是即時速度，上傳進度及剩餘時間。本篇教大家如何實作這些數據，及分享過程會遇到相關問題。&lt;/p&gt;</description></item></channel></rss>