KO
|
EN
gitlite — search
Search
#javascript
#python
#hacktoberfest
#react
#ai
#typescript
#llm
#go
#golang
#android
#machine-learning
#rust
#deep-learning
#linux
nsq-swoole
★ 13
Open GitHub ↗
PHP Swoole Consumer for NSQ
Download README (.md)
Explore Similar Repositories
Image-Editor-Python-tkinter
:
Still in progress
miqversions
:
Because naming is hard. Really, really hard.
Unity-Version-Launcher
:
Launch any of your installed versions of Unity directly from this.
grafana_plugins_practice
:
grafana插件开发
PynqRadio
:
Skeletal repository for GNU Radio WBFM implementation on Pynq board
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
nsq-swoole
?
Download (.md)
# NSQ-SWOOLE PHP Swoole client for [NSQ](https://github.com/bitly/nsq). ### Requirements - PHP 5.4 or higher - Swoole 1.8.6 or higher ### Installation composer require asan/nsq-swoole ### Testing it out Publish: php tests/PublishTest.php Subscribe: php tests/SubscribeTest.php ### Publishing The client supports publishing to N `nsqd` servers. which must be specified explicitly by hostname. And supports publishing multiple messages. ```php $client = new Asan\Nsq\Client; $client->publishTo([ ['host' => 'localhost', 'port' => 4150] ])->publish('test', 'single message'); //multiple messages $client->publish('test', ['message one', 'message two']); //HA publishing: $client->publishTo([ ['host' => 'nsq1', 'port' => 4150], ['host' => 'nsq2', /*'port' => 4150*/] ], Asan\Nsq\Client::PUB_QUORUM)->publish('test', 'HA publishing message'); ``` ### Subscribing The client supports subscribing from N `nsqd` servers, each of which will be auto-discovered from one or more `nslookupd` servers. The way this works is that `nslookupd` is able to provide a list of auto-discovered nodes hosting messages for a given topic. ```php $lookup = new Asan\Nsq\Lookup\Lookupd([ ['host' => 'nsq1', 'port' => 4161], ['host' => 'nsq2', /*'port' => 4161*/] ]); $client = new Asan\Nsq\Client; $client->subscribe($lookup, 'test', 'web', function($moniter, $msg) { echo sprintf("READ\t%s\t%s\n", $msg->getId(), $msg->getPayload()); }); ```