Add ClientConfig and ConnectionConfig, Feature Negotiation and Authentication

This commit is contained in:
2021-01-25 03:19:54 +03:00
parent 551bcfb10b
commit d9bf2a4437
11 changed files with 277 additions and 119 deletions

View File

@ -30,13 +30,13 @@ Features
- [x] PUB
- [x] SUB
- [ ] Feature Negotiation
- [X] Feature Negotiation
- [ ] Discovery
- [ ] Backoff
- [ ] TLS
- [ ] Snappy
- [X] Sampling
- [ ] AUTH
- [X] AUTH
Usage
-----
@ -71,7 +71,7 @@ use Nsq\Subscriber;
$consumer = new Consumer('tcp://nsqd:4150');
$subscriber = new Subscriber($consumer);
$generator = $subscriber->subscribe('topic', 'channel', timeout: 5);
$generator = $subscriber->subscribe('topic', 'channel');
foreach ($generator as $message) {
if ($message instanceof Message) {
$payload = $message->body;
@ -89,10 +89,6 @@ foreach ($generator as $message) {
// We can also communicate with generator through send
// for example:
// Dynamically change timeout
$generator->send(Subscriber::CHANGE_TIMEOUT);
$generator->send(10.0); // float required
// Gracefully close connection (loop will be ended)
$generator->send(Subscriber::STOP);
}