﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Sheppard Y-随笔分类-claw</title><link>http://www.cppblog.com/yangsf5/category/20857.html</link><description>keep thinking keep coding.</description><language>zh-cn</language><lastBuildDate>Wed, 13 Jul 2016 10:40:23 GMT</lastBuildDate><pubDate>Wed, 13 Jul 2016 10:40:23 GMT</pubDate><ttl>60</ttl><item><title>claw设计草稿</title><link>http://www.cppblog.com/yangsf5/archive/2014/03/31/206404.html</link><dc:creator>Sheppard Y</dc:creator><author>Sheppard Y</author><pubDate>Mon, 31 Mar 2014 03:09:00 GMT</pubDate><guid>http://www.cppblog.com/yangsf5/archive/2014/03/31/206404.html</guid><wfw:comment>http://www.cppblog.com/yangsf5/comments/206404.html</wfw:comment><comments>http://www.cppblog.com/yangsf5/archive/2014/03/31/206404.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yangsf5/comments/commentRss/206404.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yangsf5/services/trackbacks/206404.html</trackback:ping><description><![CDATA[<div><div><div><div></div><fieldset><legend><span style="color: #ff0000; line-height: normal;">2016-07-12 日更新&nbsp;</span></legend><div><span style="line-height:normal;color:red;">此篇博客已经迁移到新博客，并做行文检查和优化排版：<br /></span><div></div></div><a href="http://blog.clawz.me/2014/03/31/14-claw-design/"><div><div><span style="color:red;">http://blog.clawz.me/2014/03/31/14-claw-design/</span></div></div></a></fieldset><a href="http://blog.clawz.me/2014/03/31/14-claw-design/"><div><div></div></div><span style="orphans: 2; text-align: -webkit-auto; widows: 2;"></span></a><span style="orphans: 2; text-align: -webkit-auto; widows: 2;"><br /><font face="微软雅黑" size="3"><span style="line-height: normal;">一、目标</span></font></span><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">&nbsp; &nbsp; &nbsp;参考云风skynet，实现go版本的开源服务器引擎。</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">二、细节</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">（一）服务</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">&nbsp; &nbsp; &nbsp;按服务来拆模块的好处不说了。只说go来的实现方式。go里有channel和goroutine。消息队列和轻量级线程都天然解决了。</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">（二）服务间的通信</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">&nbsp; &nbsp; &nbsp;同进程内的服务之间通信，直接往对方channel发消息即可。不同进程里靠各进程自己的harbor服务来转发。harbor服务来负责集群间的通信。</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">&nbsp; &nbsp; &nbsp;集群里设置一个master服务来做全局的名字服务，主要用于登记和同步集群里各个进程开启的各个服务。所有harbor启动后向master注册自己，master向所有harbor广播同步新加入的这个机器。</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">（三）组播</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">&nbsp; &nbsp; &nbsp;经常需要向某几个服务广播一个消息，组播问题。multicast服务来管理组播。</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">（四）日志</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">&nbsp; &nbsp; &nbsp;使用glog。</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">三、已实现的服务</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">（一）master和harbor</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">&nbsp; &nbsp; &nbsp;暂时master做为harbor的中心控制器的。后续会改进，做成harbor之间两两通信，减少对master的单点依赖。</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">（二）gate</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">&nbsp; &nbsp; &nbsp;gate用来做通常的网络监听用。目前的很简单，用户需要向这个服务器注册自己的包解析和处理器。</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">（三）web</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">&nbsp; &nbsp; &nbsp;web负责http的监听，template的加载cache，几个通用函数的提取。</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">四、ps</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;">&nbsp; &nbsp; &nbsp;项目地址：<a href="https://github.com/yangsf5/claw">https://github.com/yangsf5/claw</a></div></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"><a href="https://github.com/yangsf5/claw"></a></div></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"></div></div><img src ="http://www.cppblog.com/yangsf5/aggbug/206404.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yangsf5/" target="_blank">Sheppard Y</a> 2014-03-31 11:09 <a href="http://www.cppblog.com/yangsf5/archive/2014/03/31/206404.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>