Serverless Frist 的漸進式應用開發框架 Malagu

{"type":"doc","content":[{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"什麼是 Malagu"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://github.com/cellbang/malagu","title":null},"content":[{"type":"text","text":"Malagu"}]},{"type":"text","text":" 是基於 TypeScript 的 Serverless First、組件化的漸進式應用開發框架。使用同一套編程語言和 IoC 設計,用於開發前端、後端和前後端一體化應用。並且結合了 OOP(面向對象編程)、AOP(面向切面編程)等元素,借鑑了很多 Spring Boot 設計思想。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在後端,Malagu 抽象一套接口,方便適配任意的平臺和基礎框架,是一個平臺或基礎框架無關的上層框架。平臺如阿里雲函數計算、騰訊云云函數、Vercel 等,基礎框架如 Express、Koa、Fastify 等。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"爲什麼需要 Malagu"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"堅信 Serverless 是未來"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Serverless 是雲計算新一代計算引擎,爲取代傳統雲服務器架構而生。Serverless 核心理念是讓開發者不用關心服務器的存在,專注於業務代碼。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"Serverless 現狀如何"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"現在,所有云廠商和社區都在大力推廣和佈道 Serverless 理念,通過 Serverless 可以低成本高質量快速落地商業方案。目前,大家普遍認爲 Serverless = FaaS + BaaS,未來也可能是其他的形態,不管形態如何變化,Serverless 的核心理論是不變的。所有 Serverless 的開發體驗關鍵在 FaaS 的開發體驗,而 FaaS 目前開發體驗不是很理想,存在着很多的疼點,短時間內在 FaaS 底層上很難解決,比如冷啓動、數據庫訪問、本地開發調試運行、平臺無關等等。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"如何解決這些痛點"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我們可以換一個思路,從開發框架層面嘗試解決這些問題(事實證明,可以通過開發框架來解決這些問題)。那麼,我們面臨新的抉擇是採用傳統框架,還是需要一個全新的框架?如果選擇做一個新框架,那麼,我們是選擇特定編程語言,還是通用編程語言?"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"爲什麼需要一個全新的框架"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"傳統框架在開發體驗上,大家肯定是接受的,畢竟已經使用了這麼多年。但是傳統框架開發的應用在遷移到 Serverless 環境時,往往會遇到各種各樣難以解決的問題,這些問題往往是與框架底層設計密切相關。雖然我們可以通過框架擴展能力去解決或者緩解部分問題,實踐下來的結果是框架改造門檻很高、效果不太理想、需要 Hack,不夠優雅。當您在 Serverless 採用傳統框架時,您往往會感覺雖然應用可以跑起來,但是真正應用到生產級別您會有顧慮。所有我們需要一個全新的、Serverless Fisrt 的開發框架。只有這樣才能極大發揮 Serverless 優勢,並讓 Serverless 開發體驗超越傳統開發體驗。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"爲什麼選擇特定編程語言"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"目前,開源社區也存在不少語言無關的 Serverless 工具或框架,比如 Funcraft、Serverless Framework、Vercel 等等。這類通用語言型 Serverless 工具在運維層面確實可以做到不錯的體驗,也可以形成通用的標準。但是,在應用代碼開發、調試、運行等開發體驗上不那麼理想。每種編程語言在開發、調試和運行等方面都有自己獨特的地方,通用語言型 Serverless 工具很難做到統一,且開發體驗還能做到很好。只有選擇特定的編程語言,才能讓開發、調試和運行等方面的體驗達到極致。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"爲什麼選擇 Typescript"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Serverless 讓後端開發門檻變得極低,前端開發者基於 Serverless 開發後端應用學習成本也極低。未來越來越多的前端開發者成爲全棧開發者。Typescript 既可以開發前端,又可以開發後端,對於前端或者全棧的開發者來說十分友好。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"前端架構其實就是一種類 Serverless 架構,比如前端瀏覽器需要加載前端代碼來執行,而 Serverless 場景也需要加載用戶的代碼來執行。因此,前端的很多解決方案天然適合 Serverless 場景,比如前端通過打包、壓縮、Tree Shaking 來減少代碼體積,減少代碼部署和冷啓動時間。同樣,該優化方案也適用與 Serverless 場景,所以選擇 Typescript,則相當於直接擁有了經過無數真實場景打磨的現成解決方案。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"另外,Typescript 和 Java 很接近,Java 開發者也能很方便切換到 Typescript 技術棧。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"Malagu 帶來的價值"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Malagu 是基於 TypeScript 的 Serverless First、可擴展和組件化的漸進式應用開發框架。Malagu 屏蔽掉不同 Serverless 平臺底層細節和 Serverless 場景存在的大部分痛點。Malagu 基於真實業務場景打磨,提供生產級別可用的解決方案。提供多雲解決方案,雲廠商不鎖定。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"如何使用 Malagu"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Malagu 框架是由一系列組件組成,每一個組件其實就是一個 node 模塊,根據您的業務場景選擇合適的組件,您也可以基於組件機制開發屬於自己的組件。爲了快速開發,Malagu 提供了一個命令行工具,命令行工具內置不同場景的開箱即用的模板,通過命令行工具可以快速創建您的應用。首先,我們需要安裝相關命令行工具:"}]},{"type":"codeblock","attrs":{"lang":null},"content":[{"type":"text","text":"$ npm install -g yarm # 框架默認推薦使用 Yarn 工具,您也可以使用 Npm\n$ npm install -g @malagu/cli # 安裝 Malagu 命令行工具\n$ malagu init project-name # 使用命令行工具 malagu init 命令,選擇一個模板,初始化一個模板應用\n$ cd project-name # 進入到應用的根目錄\n$ malagu serve # 啓動應用,默認端口爲 3000"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"打開瀏覽器並導航到 "},{"type":"link","attrs":{"href":"http://localhost:3000/","title":null},"content":[{"type":"text","text":"http://localhost:3000/"}]},{"type":"text","text":"。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"支持我們"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Malagu 是 MIT 許可的開源項目。需要優秀人士的支持使它不斷髮展。如果您想加入我們,請聯繫我們,我們的郵箱是 "},{"type":"text","marks":[{"type":"strong"}],"text":"[email protected]"},{"type":"text","text":"。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"相關鏈接"}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://link.zhihu.com/?target=https%3A//github.com/cellbang/malagu","title":null},"content":[{"type":"text","text":"Malagu 框架項目地址"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://link.zhihu.com/?target=https%3A//www.yuque.com/cellbang/malagu","title":null},"content":[{"type":"text","text":"Malagu 框架文檔地址"}]}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章