.NET微服務架構及API網關
阿新 • • 發佈:2018-03-05
.dll 除了 nqa targe tor scrip art src protobuf
MSA服務端的架構
在MSA API可視化說明文檔中顯示各請求參數、響應的含義說明
Metadata頁
MSA接口註冊頁
所有服務通過一個API網關來暴露
在自主開發的API網關後臺管理子系統中配置網關參數
SOA實現 | 微服務架構實現 | |
企業級,自頂向下開展實施 | 團隊級,自底向上開展實施 | |
粒度大:服務由多個子系統組成 | 粒度細:一個系統被拆分成多個服務,且服務的定義更加清晰 | |
重ESB:企業服務總線,集中式的服務架構 | 輕網關:無集中式總線,松散的服務架構 | |
開發過程復雜 | 易開發:減少了企業ESB開發的復雜性,與敏捷開發的思想高度結合在一起 | |
單塊架構系統,相互依賴,部署復雜 | 服務能被獨立部署 | |
![技術分享圖片](http://image.bubuko.com/info/201803/20180305140529132362.png)
![技術分享圖片](http://image.bubuko.com/info/201803/20180305140529329615.png)
1 Plugins.Add(new ValidationFeature()); 2 container.RegisterValidator(typeof(OrderValidator));
1 Plugins.Add(new ProtoBufFormat());
1 TResponse Get<TResponse>(IReturn<TResponse> requestDto);
1 Plugins.Add(new SwaggerFeature());
![技術分享圖片](/img/fz.gif)
1 public class OrderRequest : IReturn<OrderResponse> 2 { 3 [ApiMember(Name = "Id", Description = "訂單ID號", IsRequired = false)] 4 public int Id { get; set; } 5 [ApiMember(Name = "CustomerName", Description = "客戶名", IsRequired = false)] 6 public string CustomerName { get; set; } 7 //...... 8 [ApiMember(Name = "OrderItemList", Description = "訂購的產品列表", IsRequired = false)] 9 public List<OrderItem> OrderItemList { get; set; } 10 }
![技術分享圖片](/img/fz.gif)
![技術分享圖片](http://image.bubuko.com/info/201803/20180305140529403829.png)
![技術分享圖片](http://image.bubuko.com/info/201803/20180305140529480973.png)
![技術分享圖片](http://image.bubuko.com/info/201803/20180305140529583505.png)
![技術分享圖片](http://image.bubuko.com/info/201803/20180305140529654790.png)
![技術分享圖片](http://image.bubuko.com/info/201803/20180305140529798335.png)
![技術分享圖片](http://image.bubuko.com/info/201803/20180305140529901844.png)
![技術分享圖片](http://image.bubuko.com/info/201803/20180305140530017071.png)
API Gateway主要實現以下功能:
![技術分享圖片](http://image.bubuko.com/info/201803/20180305140530119604.png)
.NET微服務架構及API網關