iris / nsq_to_swoole
使用swoole扩展的强大PHP客户端,用于NSQ
1.2.2
2017-11-14 00:58 UTC
Requires
- php: >=5.5
- ext-swoole: >=1.8.6
- ixudra/curl: 6.*
This package is not auto-updated.
Last update: 2024-09-23 19:20:23 UTC
README
使用swoole扩展的强大PHP客户端,用于NSQ
必要组件
- PHP >= 5.5
- Swoole >= 1.8.6
安装
pecl install swoole
composer require iris/nsq_to_swoole
发布
客户端支持NSQ服务器集群,同时支持单条消息多条消息发送
$hosts = [ ['host' => '192.168.9.135', 'port' => 4150], ]; $client = new Iris\NsqToSwoole\Client; $client->setTarget($hosts, 1); $client->pub('examples', 'Hello From iris-xie', 1);
订阅
首先通过lookup获取列表,然后才能订阅
$lookup = new Iris\NsqToSwoole\Lookup\Lookupd([ ['host' => '192.168.9.135', 'port' => 4161], ]); $client = new Iris\NsqToSwoole\Client; $client->sub($lookup, 'examples', 'example', function($moniter, $msg) { echo sprintf("READ\t%s\t%s\n", $msg->getId(), $msg->getPayload()); });
使用示例
cd nsq_to_swoole/examples
发布(Pub)
php Pub.php
订阅(Sub)
php Sub.php