SwooleDistributed 2.3.0 版本更新

综合技术 2017-08-15

SwooleDistributed2.3.0版本更新

1.TimerTask,Reload,Consul的服务监听都合并为了一个新进程SDHelpProcess,TimerTask现在通过内部Rpc可以负载均衡的通知各个wokrer进程执行相关任务了。

2.TimerTask可以通过Consul配置实时更新,通过修改consul中的配置可以在多台SD服务器上实现任务的同步

3.借助Consul实现了leader选举,通过ConsulHelp::isLeader可以得知本机是否是leader。

4.新增Process模块,可以借助此模块快速构建用户进程,默认开启协程和异步模式。并且提供了便捷的进程中RPC的方法。

class MyProcess extends Process
{
    public function start($process)
    {
        parent::start($process);
    }

    public function getData()
    {
        return '123';
    }
}
    /**
     * 测试进程
     */
    public function http_testProcess()
    {
        $result = yield ProcessManager::getInstance()->getRpcCall(MyProcess::class)->getData();
        $this->http_output->end($result);
    }

5.修改并统一了框架中进程间通讯和消息派发的方式,通过EventDispatcher更好的管理消息的派发。

        //监听服务改变
        EventDispatcher::getInstance()->add(ConsulHelp::DISPATCH_KEY, function (Event $event) {
            ConsulHelp::getMessgae($event->data);
        });
        //监听leader改变
        EventDispatcher::getInstance()->add(ConsulHelp::LEADER_KEY, function (Event $event) {
            ConsulHelp::leaderChange($event->data);
        });
开源中国

责编内容by:开源中国 (源链)。感谢您的支持!

您可能感兴趣的

CodeSOD: Synchronized Threads Timwas debugging one of those multithreading bugs, where there appeared to be a race condition of s...
iHerb(上海)招聘产品经理,年薪30~50万... iHerb 是一家位于美国的电商平台,向全世界 150 多个国家提供高性价比的天然健康产品,在加州、肯塔基州和宾夕法尼亚州拥有三个经过 GMP 认证的现代化绿色环保仓库,超过 1200...
What Happened to the “Surgical Team” Pattern from ... Years ago, when I read The Mythical Man-Month, I found lots of stuff which I already knew from other...
Paytm Interview Experience | Set 19 (On Campus – S... Round 1: 3 Coding Questions. Different question for different persons. 1 question onstring mani...
Breaking Down Binary Ninja’s Low Level IL Hi, I’m Josh. I recently joined the team at Trail of Bits, and I’ve been an evangelist and plugin w...