Surging 自2017年6月16日開源以來,已收到很多公司的關注或者使用,其中既有以海克斯康超大型等外企的關注,也不乏深圳泓達康、重慶金翅膀等傳統行業的正式使用,自2019年年初,surging2.0 便已正式進入研發階段,也受到了surging 用戶的關注,本文將爲您解讀2.0的新特性和新功能。在開始以前先解答一下常常被提到的疑問git
1.Surging 有沒有文檔、Demo、官網github
由於須要完善Surging,暫時我的尚未時間去寫文檔,準備官網,可是你們能夠經過關注liuhll,由於他正在寫surging文檔和 基於surging 的案例,算法
liuhll 文檔:https://liuhll.github.io/hexo-blog-deploy/categories/%E5%BE%AE%E6%9C%8D%E5%8A%A1/json
surging案例:https://github.com/liuhll/Surging.Sample緩存
2. Surging 有沒有公司正在使用hexo
由於Surging 是開源產品,沒法統計哪家公司正在使用,因此我提交了《surging 誰在使用》的issues, 你們能夠去查看issues來知曉哪家公司正在使用,也請使用了surging的公司留下你所在公司的聯繫方式,以便收集有意向在生產上使用surging的客戶,從而讓surging社區和donetcore生態變得更加繁榮。ide
3. 什麼時候支持Stage組件模塊化
對於Surging如今有一套獨立的 surging 網關,而網關的設計違反了引擎組件化思想, 因此新的版本會基於KestrelHttpServer 組件擴展Stage,這樣就能以組件模塊化生成,以代替以前網關沒法作到的緩存服務降級,複雜業務服務的聚合,文件服務的支持,大概8月底完工微服務
4. 是否會支持灰度發佈組件化
由於.net core 設計問題,暫時沒法作到surging 灰度發佈, 已將問題提交給coreclr,現已獲得解決,等到3.0發佈後,surging 也會開始支持灰度發佈。
Surging 能夠支持pull 和 push 兩種方式來更新服務路由,而這兩種方式是由consul 和zookeeper 來實現的,而pull 是利用心跳的方式,而 push 是利用Watch 的機制,而 同時 註冊中心能夠支持向多個註冊中心註冊服務路由,以同步註冊服務。當基於pull 和watch更新的時候,能夠經過隨機算法來負載獲取最新的服務路由來更新本地路由,能夠經過如下代碼配置多註冊中心
Consul (surgingSettings.json):
"Consul": { "ConnectionString": "${Register_Conn}|127.0.0.1:8500,127.0.0.1:9500", "SessionTimeout": "${Register_SessionTimeout}|50", "RoutePath": "${Register_RoutePath}", "ReloadOnChange": true, "EnableChildrenMonitor": false }
Zookeeper(surgingSettings.json)
Zookeeper:{ "ConnectionString": "${Zookeeper_ConnectionString}|127.0.0.1:2181, 127.0.0.1:2281", "SessionTimeout": 50, "ReloadOnChange": true }
ApiGateway
"Register": { "Provider": "Consul", "Address": "${Register_Conn}|127.0.0.1:8500,127.0.0.1:9500" }
ASP.NET Core Web API 使用Swagger 能夠生成在線幫助測試文檔,而surging 維護了一套 基於surging 的swagger 的引擎組件,以便支持業務模塊使用Swagger 生成在線幫助測試文檔。具體能夠按照如下代碼進行配置:
"Swagger": { "Info": { "Version": "${SwaggerVersion}|V1", // "127.0.0.1:8500", "Title": "${SwaggerTitle}|Surging Demo", "Description": "${SwaggerDes}|surging demo", "Contact": { "Name": "API Support", "Url": "https://github.com/dotnetcore/surging", "Email": "fanliang1@hotmail.com" }, "License": { "Name": "MIT", "Url": "https://github.com/dotnetcore/surging/blob/master/LICENSE" } }, "Options": { "IgnoreFullyQualified": true } }
而針對於業務模塊生產的測試文檔,咱們能夠經過設置AssemblyInfo.cs,具體代碼以下:
using System.Reflection; [assembly: AssemblyTitle("CommonModule")] [assembly: AssemblyDescription("業務模塊")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("fanly")] [assembly: AssemblyProduct("surging Micro Service Framework")] [assembly: AssemblyCopyright("Copyright © fanly All Rights Reserved.")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: AssemblyVersion("1.1.0.0")] [assembly: AssemblyFileVersion("1.1.0.0")]
界面生成以下:
但願你們研究下surging ,surging 會讓你對.NET CORE微服務有個全新的認識,也但願你們大力宣傳,讓surging 發展愈來愈好。