KO
|
EN
gitlite — search
Search
#python
#java
#python3
#arduino
#golang
#machine-learning
#rust
#html
#flask
#javascript
#seismology
#nodejs
nsqclient-php
★ 22
Open GitHub ↗
Yet another PHP client for NSQ
Download README (.md)
Explore Similar Repositories
puppy
:
the puppy proxy
SA1_Chars
:
Sonic Adventure character models in SADX
ClipMd
:
简化markdown的写作的贴图流程,快捷键-快速把剪切板的截图粘贴到markdown,使用github仓库,不依赖其他的服务器
golang-rpi-extras
:
Some extra interfaces to peripherals found for Arduino and stuff, but in Go and for Raspberry Pi.
devpreferences
:
These are my own preferences while doing development.
// 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
nsqclient-php
?
Download (.md)
# NSQClient Yet another PHP client for [NSQ](http://nsq.io) ### Installation (via composer) ``` composer require moolex/nsqclient dev-master ``` ### Usage #### Publish ```php $topic = 'my_topic'; $endpoint = new \NSQClient\Access\Endpoint('http://127.0.0.1:4161'); $message = new \NSQClient\Message\Message('hello world'); $result = \NSQClient\Queue::publish($endpoint, $topic, $message); ``` #### Publish (deferred) ```php $topic = 'my_topic'; $endpoint = new \NSQClient\Access\Endpoint('http://127.0.0.1:4161'); $message = (new \NSQClient\Message\Message('hello world'))->deferred(5); $result = \NSQClient\Queue::publish($endpoint, $topic, $message); ``` #### Publish (batch) ```php $topic = 'my_topic'; $endpoint = new \NSQClient\Access\Endpoint('http://127.0.0.1:4161'); $message = \NSQClient\Message\Bag::generate(['msg data 1', 'msg data 2']); $result = \NSQClient\Queue::publish($endpoint, $topic, $message); ``` #### Subscribe ```php $topic = 'my_topic'; $channel = 'my_channel'; $endpoint = new \NSQClient\Access\Endpoint('http://127.0.0.1:4161'); \NSQClient\Queue::subscribe($endpoint, $topic, $channel, function (\NSQClient\Contract\Message $message) { echo 'GOT ', $message->id(), "\n"; // make done $message->done(); // make retry immediately // $message->retry(); // make retry delayed in 10 seconds // $message->delay(10); }); ```