zooland 新開源的RPC項目,希望大家在開發的微服務的時候多一種選擇,讓微服務開發簡單,并且容易上手。...

zooland 我叫它動物園地,一個構思很長時間的一個項目。起初只是覺得各種通信框架都封裝的很好了,但是就是差些兼容,防錯,高可用。同時在使用上,不希望有多余的代碼,像普通接口一樣使用就可以了。

基于這些想法,看了很多資料,有了很多啟發;也開發出這樣一個版本,而且也在實際項目中應用起來了,算是小有成就吧。但同時深知一個人的力量有限,希望得到整個社區幫助。幫助我完善它,讓它成為.net 平臺下一個不錯的選擇。

首先,介紹一下這個項目。

項目中沒有實現自己的通信層代碼,因為大廠為我們提供了 比如 thrift、grpc、HTTP、wcf、akka.net、netty.net 等等。

其次既然我都支持了這么多種通信框架了,那么他們在同一個項目中進行混用也是可以的。比如你的.net 項目內使用wcf 或 netty通信,這個時候elk或者搜索引擎為你提供了thrift的接口,那么用這個框架會是不錯的選擇。

項目中 主要的精力放在了LoadBalace、調用錯誤隔離、重試、緩存,多種形式的Cluster、以及如何以最簡單的方式讓隊員通過直鏈的方式進行開發。

服務注冊和發現,現在還沒有很好的實現想法,希望社區能幫忙,當然有接口性能監控的能手,和調用鏈或熟悉dapper的能加入我,那么我會更高興。

ioc上無賴選擇了Spring.net,希望spring.net 早點出.net core版本的,這樣我會很省心的去開發.net core 版的zooland;

autofac 我正在嘗試,希望能作為spring.net 的替代版本,可能是因為習慣了spring.net 感覺autofac我增加我的配置文檔的數量,這是我不喜歡的

ioc 我也不喜歡對框架內部侵入太多的,它會讓我覺得我的架構很臃腫,讓我覺得ioc 不過是虛擬工廠來生產真正的實例,而且還要讓我到處引用虛擬工廠的類庫,想想都覺得煩。

計劃還是有的:

準備在框架層加入過濾器,這樣CAS 做分布式事務的開源框架也能整合進來,緩存也能獨立成一個Filter 的實現

比較麻煩的是調用鏈,需要埋點,由于支持了多種通信框架,而基于dapper論文的追蹤訪問鏈條的方式,可能導致有些通信框架不支持,比較麻煩,一直在想,tcp/ip協議是不是也有想http一樣的,可以在訪問header里面添加調用鏈的內容。也希望社區有好的辦法。當然能推動大廠們提供的通信框架的改進,那就更好了。

有代碼有真相,下面是用于調用的代碼,對使用來說絕對easy

static void Main(string[] args){var context = ContextRegistry.GetContext();var helloServiceThrift = context.GetObject<RpcContractThrift.IHelloService>();var helloServiceGrpc = context.GetObject<RpcContractGrpc.IHelloService>();var helloServiceWcf = context.GetObject<RpcContractWcf.IHelloService>();var helloServiceHttp = context.GetObject<RpcContractHttp.IHelloService>();var helloServiceAkka = context.GetObject<RpcContractAkka.IHelloService>();var helloServiceRemoting = context.GetObject<RpcContractRemoting.IHelloService>();while (true){Console.WriteLine("請選擇:wcf | grpc | thrift | http | akka | remoting");var mode = Console.ReadLine().ToLower();switch (mode){case "wcf":CallWhile((helloword) => { WcfHello(helloServiceWcf, helloword); });break;case "grpc":CallWhile((helloword) => { GrpcHello(helloServiceGrpc, helloword); });break;case "thrift":CallWhile((helloword) => { ThriftHello(helloServiceThrift, helloword); });break;case "http":CallWhile((helloword) => { HttpHello(helloServiceHttp, helloword); });break;case "akka":CallWhile((helloword) => { AkkaHello(helloServiceAkka, helloword); });break;case "remoting":CallWhile((helloword) => { RemotingHello(helloServiceRemoting, helloword); });break;case "all":for (int i = 0; i < 3; i++){Task.Run(() =>{try{WcfHello(helloServiceWcf);}catch (Exception ex){throw ex;}});Task.Run(() =>{try{GrpcHello(helloServiceGrpc);}catch (Exception ex){throw ex;}});Task.Run(() =>{try{ThriftHello(helloServiceThrift);}catch (Exception ex){throw ex;}});Task.Run(() =>{try{HttpHello(helloServiceHttp);}catch (Exception ex){throw ex;}});Task.Run(() =>{try{AkkaHello(helloServiceAkka);}catch (Exception ex){throw ex;}});}break;}if (mode == "end"){break;}}}private static void ThriftHello(RpcContractThrift.IHelloService helloServiceThrift, string helloword = "world"){var callNameVoid = helloServiceThrift.CallNameVoid();Console.WriteLine(callNameVoid);helloServiceThrift.CallName(helloword);Console.WriteLine("CallName called");helloServiceThrift.CallVoid();Console.WriteLine("CallVoid called");var hello = helloServiceThrift.Hello(helloword);Console.WriteLine(hello);var helloResult = helloServiceThrift.SayHello(helloword + "perfect world");Console.WriteLine($"{helloResult.Name},{helloResult.Gender},{helloResult.Head}");helloResult.Name = helloword + "show perfect world";var showResult = helloServiceThrift.ShowHello(helloResult);Console.WriteLine(showResult);}private static void GrpcHello(RpcContractGrpc.IHelloService helloServiceGrpc, string helloword = "world"){var callNameVoid = helloServiceGrpc.CallNameVoid(new RpcContractGrpc.Void());Console.WriteLine(callNameVoid);helloServiceGrpc.CallName(new RpcContractGrpc.NameResult { Name = helloword });Console.WriteLine("CallName called");helloServiceGrpc.CallVoid(new RpcContractGrpc.Void());Console.WriteLine("CallVoid called");var hello = helloServiceGrpc.Hello(new RpcContractGrpc.NameResult { Name = helloword });Console.WriteLine(hello.Name);var helloResult = helloServiceGrpc.SayHello(new RpcContractGrpc.NameResult { Name = $"{helloword} perfect world" });Console.WriteLine($"{helloResult.Name},{helloResult.Gender},{helloResult.Head}");helloResult.Name = helloword + "show perfect world";var showResult = helloServiceGrpc.ShowHello(helloResult);Console.WriteLine(showResult.Name);}private static void WcfHello(RpcContractWcf.IHelloService helloServiceWcf, string helloword = "world"){var callNameVoid = helloServiceWcf.CallNameVoid();Console.WriteLine(callNameVoid);helloServiceWcf.CallName(helloword);Console.WriteLine("CallName called");helloServiceWcf.CallVoid();Console.WriteLine("CallVoid called");var helloWcf = helloServiceWcf.Hello(helloword);Console.WriteLine(helloWcf);var helloResultWcf = helloServiceWcf.SayHello($"{helloword} perfect world");Console.WriteLine($"{helloResultWcf.Name},{helloResultWcf.Gender},{helloResultWcf.Head}");helloResultWcf.Name = helloword + "show perfect world";var showResultWcf = helloServiceWcf.ShowHello(helloResultWcf);Console.WriteLine(showResultWcf);}private static void HttpHello(RpcContractHttp.IHelloService helloServiceHttp, string helloword = "world"){var callNameVoid = helloServiceHttp.CallNameVoid();Console.WriteLine(callNameVoid);helloServiceHttp.CallName(helloword);Console.WriteLine("CallName called");helloServiceHttp.CallVoid();Console.WriteLine("CallVoid called");var helloWcf = helloServiceHttp.Hello(helloword);Console.WriteLine(helloWcf);var helloResultWcf = helloServiceHttp.SayHello($"{helloword} perfect world");Console.WriteLine($"{helloResultWcf.Name},{helloResultWcf.Gender},{helloResultWcf.Head}");helloResultWcf.Name = helloword + "show perfect world";var showResultWcf = helloServiceHttp.ShowHello(helloResultWcf);Console.WriteLine(showResultWcf);}private static void AkkaHello(RpcContractAkka.IHelloService akkaServiceHttp,string helloword = "world"){var callNameVoid = akkaServiceHttp.CallNameVoid();Console.WriteLine(callNameVoid);akkaServiceHttp.CallName(new RpcContractAkka.NameResult { Name = helloword });Console.WriteLine("CallName called");akkaServiceHttp.CallVoid();Console.WriteLine("CallVoid called");var hello = akkaServiceHttp.Hello(new RpcContractAkka.NameResult { Name = helloword });Console.WriteLine(hello.Name);var helloResult = akkaServiceHttp.SayHello(new RpcContractAkka.NameResult { Name = $"{helloword} perfect world" });Console.WriteLine($"{helloResult.Name},{helloResult.Gender},{helloResult.Head}");helloResult.Name = helloword + "show perfect world";var showResultWcf = akkaServiceHttp.ShowHello(helloResult);Console.WriteLine(showResultWcf.Name);}private static void RemotingHello(RpcContractRemoting.IHelloService remotingServiceHttp, string helloword = "world"){var callNameVoid = remotingServiceHttp.CallNameVoid();Console.WriteLine(callNameVoid);remotingServiceHttp.CallName(helloword);Console.WriteLine("CallName called");remotingServiceHttp.CallVoid();Console.WriteLine("CallVoid called");var hello = remotingServiceHttp.Hello(helloword);Console.WriteLine(hello);var helloResult = remotingServiceHttp.SayHello($"{helloword} perfect world");Console.WriteLine($"{helloResult.Name},{helloResult.Gender},{helloResult.Head}");helloResult.Name = helloword + "show perfect world";var showResult = remotingServiceHttp.ShowHello(helloResult);Console.WriteLine(showResult);}private static void CallWhile(Action<string> map){var helloword = "world";while (true){try{map(helloword);var mode = Console.ReadLine().ToLower();helloword = mode;if (helloword == "end"){break;}}catch (Exception ex){Console.WriteLine(ex.StackTrace);}}}}

目前只支持了spring.net ,有autofac的高手,歡迎加入

希望為一部分使用.net framework 的WCF做通信層框架,轉微服務架構,作為一個不錯的并且平滑的升級選擇。

新技術不要怕不穩定,源碼都有了,而且框架結構這么簡單,大膽用,有問題了,可以聯系技術支持啥。

奉上項目開源地址:

https://github.com/wutao0315/zooland

現在還沒有搞明白怎么編譯好一個版本怎么弄到nuget上,而且版本管理經驗也欠缺,也需要依賴社區了。

聯系作者

mail:wutao0315@qq.com

qq:1164636434

想加入我的,郵件給我吧,歡迎每一個熱愛編程的同學。

轉載于:https://www.cnblogs.com/jweiswu/p/zooland.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/390003.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/390003.shtml
英文地址,請注明出處:http://en.pswp.cn/news/390003.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

187. 重復的DNA序列

187. 重復的DNA序列 所有 DNA 都由一系列縮寫為 ‘A’&#xff0c;‘C’&#xff0c;‘G’ 和 ‘T’ 的核苷酸組成&#xff0c;例如&#xff1a;“ACGAATTCCG”。在研究 DNA 時&#xff0c;識別 DNA 中的重復序列有時會對研究非常有幫助。 編寫一個函數來找出所有目標子串&am…

牛客網_Go語言相關練習_選擇題(2)

注&#xff1a;題目來源均出自牛客網。 一、選擇題 Map&#xff08;集合&#xff09;屬于Go的內置類型&#xff0c;不需要引入其它庫即可使用。 Go-Map_菜鳥教程 在函數聲明中&#xff0c;返回的參數要么都有變量名&#xff0c;要么都沒有。 C選項函數聲明語法有錯誤&#xff0…

機器學習模型部署_9月版部署機器學習模型

機器學習模型部署每月版 (MONTHLY EDITION) Often, the last step of a Data Science task is deployment. Let’s say you’re working at a big corporation. You’re building a project for a customer of the corporation and you’ve created a model that performs well…

352. 將數據流變為多個不相交區間

352. 將數據流變為多個不相交區間 給你一個由非負整數 a1, a2, …, an 組成的數據流輸入&#xff0c;請你將到目前為止看到的數字總結為不相交的區間列表。 實現 SummaryRanges 類&#xff1a; SummaryRanges() 使用一個空數據流初始化對象。void addNum(int val) 向數據流中…

Java常用的八種排序算法與代碼實現

排序問題一直是程序員工作與面試的重點&#xff0c;今天特意整理研究下與大家共勉&#xff01;這里列出8種常見的經典排序&#xff0c;基本涵蓋了所有的排序算法。 1.直接插入排序 我們經常會到這樣一類排序問題&#xff1a;把新的數據插入到已經排好的數據列中。將第一個數和第…

熊貓ai智能機器人量化_機器學習中的熊貓是什么

熊貓ai智能機器人量化Machine learning is a complex discipline. The implementation of machine learning models is now far much easier than it used to be, this is as a result of Machine learning frameworks such as pandas. Wait!! isnt panda an animal? As I rec…

441. 排列硬幣

441. 排列硬幣 你總共有 n 枚硬幣&#xff0c;并計劃將它們按階梯狀排列。對于一個由 k 行組成的階梯&#xff0c;其第 i 行必須正好有 i 枚硬幣。階梯的最后一行 可能 是不完整的。 給你一個數字 n &#xff0c;計算并返回可形成 完整階梯行 的總行數。 示例 1&#xff1a;…

調用百度 Echarts 顯示重慶市地圖

因為 Echarts 官方不再提供地圖數據的下載&#xff0c;在這里保存一份&#xff0c;供日后使用&#xff0c;重慶地圖數據的 JSON 文件在 CSDN 上下載。 <!DOCTYPE html> <html style"height: 100%"><head><meta charset"utf-8"><…

JEESZ-SSO解決方案

2019獨角獸企業重金招聘Python工程師標準>>> 第一節&#xff1a;單點登錄簡介 第一步&#xff1a;了解單點登錄 SSO主要特點是: SSO應用之間使用Web協議(如HTTPS)&#xff0c;并且只有一個登錄入口. SSO的體系中有下面三種角色: 1) User(多個) 2) Web應用(多個) 3) …

女朋友天天氣我怎么辦_關于我的天氣很奇怪

女朋友天天氣我怎么辦帶有扭曲的天氣應用 (A Weather App with a Twist) Is My Weather Weird?? is a weather app with a twist — it offers a simple answer to a common question we’ve all asked. To do this we look at how often weather like today’s used to happ…

Java中length,length(),size()的區別

&#xff08;一&#xff09;區別&#xff1a; ①length&#xff1a;用于算出數組的長度。 ②length&#xff08;&#xff09;&#xff1a;用于找出字符串的長度。 ③size&#xff08;&#xff09;&#xff1a;用于找出泛型集合的元素個數。轉載于:https://www.cnblogs.com/not-…

5895. 獲取單值網格的最小操作數

5895. 獲取單值網格的最小操作數 給你一支股票價格的數據流。數據流中每一條記錄包含一個 時間戳 和該時間點股票對應的 價格 。 不巧的是&#xff0c;由于股票市場內在的波動性&#xff0c;股票價格記錄可能不是按時間順序到來的。某些情況下&#xff0c;有的記錄可能是錯的…

為什么要用Redis

最近閱讀了《Redis開發與運維》&#xff0c;非常不錯。這里對書中的知識整理一下&#xff0c;方便自己回顧一下Redis的整個體系&#xff0c;來對相關知識點查漏補缺。我按照五點把書中的內容進行一下整理&#xff1a;為什么要選擇Redis&#xff1a;介紹Redis的使用場景與使用Re…

第一次馬拉松_成為數據科學家是一場馬拉松而不是短跑

第一次馬拉松Since Data Science became the “Sexiest Job of the 21st Century” the interest in the field has grown tremendously. With it so have the courses available to gain the necessary knowledge. As great as this is, the downside is a field marketed as …

273. 整數轉換英文表示

273. 整數轉換英文表示 將非負整數 num 轉換為其對應的英文表示。 示例 1&#xff1a;輸入&#xff1a;num 123 輸出&#xff1a;"One Hundred Twenty Three" 示例 2&#xff1a;輸入&#xff1a;num 12345 輸出&#xff1a;"Twelve Thousand Three Hundred…

Java-運算符

算術運算符 加法 相加運算符兩側的值- 減法 左操作數減去右操作數* 乘法 相乘操作符兩側的值/ 除法 左操作數除以右操作數&#xff08;int類型的數相除時&#xff0c;會得到int類型的值&#xff0c;如果結果有小數&#xff0c;則小數部分會被舍棄&#xff09;% 模余運算&…

區塊鏈開發公司談區塊鏈在商業上的應用

對于近期正受科技界和資本市場關注的區塊鏈行業&#xff0c;一句話概括說如果互聯網技術解決的是通訊問題的話&#xff0c;區塊鏈技術解決的是信任問題&#xff0c;其在商業領域應用如何呢&#xff1f;我們來從兩個方面去進行剖析。 第一方面&#xff0c;區塊鏈技術可以解決基礎…

ORACLE1.21 PLSQL 01

-- 有了SQL 為什么還需要PL/SQL -- SQL功能很強大&#xff0c;但如果是單1sql語句&#xff0c;沒有流程控制 -- PL/SQL 是什么&#xff1f; --不僅僅實現流程控制&#xff0c;同時保留SQL本身所有的功能 --還提供變量、常量等支持 --提供更多數據類型的支持 --第一&#xff0c;…

云原生數據庫_數據標簽競賽云原生地理空間沖刺

云原生數據庫STAC specification is getting closer to the ver 1.0 milestone, and as such the first virtual Cloud Native Geospatial Sprint is being organized next week. An outreach day is planned on Sep 8th with a series of talks and tutorials for everyone. R…

Linux 下的 hosts文件

2019獨角獸企業重金招聘Python工程師標準>>> hosts 文件 目錄在 /etc/hosts netstat -ntlp //linux 下查看端口 轉載于:https://my.oschina.net/u/2494575/blog/1923074