quinluong/miczone-wrapper-php
最新稳定版本:1.0.2
Composer 安装命令:
composer require quinluong/miczone-wrapper-php
包简介
Miczone wrapper for php
README 文档
README
Installation
This library can be installed via Composer:
composer require quinluong/miczone-wrapper-php
Test
./vendor/phpunit/phpunit/phpunit --verbose tests ./vendor/phpunit/phpunit/phpunit --verbose tests/Miczone/Wrapper/MiczoneCatalogClient/GatewayTest.php --filter testPing ./vendor/phpunit/phpunit/phpunit --repeat 10 --verbose tests
EventBus
Prerequisite libraries
In order to use this library, must be install by following https://github.com/arnaud-lb/php-rdkafka#installation
-
Step 1: Install librdkafka https://github.com/edenhill/librdkafka
-
Step 2: Install rdkafka https://arnaud.le-blanc.net/php-rdkafka-doc/phpdoc/rdkafka.installation.pecl.html
Please choose version rdkafka-3.1.3 for high stability
Usage
Notifier
use Miczone\Wrapper\MiczoneEventBusClient\Notifier; use Miczone\Thrift\EventBus\NotifyMessageResponse; $client = new Notifier([ 'hosts' => '127.0.0.1:1234', 'clientId' => 'my-service', 'auth' => 'user:pass', 'topics' => 'topicA,topicB', 'numberOfRetries' => 3 // optional ]); // Async $client->ow_notifyString([ 'topic' => 'topicA', 'key' => 'my-key', // to keep packages in order if they have the same key 'data' => '{}' // data type can be Boolean / Integer / Double / String ], function () { // Success callback }, function ($ex) { // Error callback }); // Sync, type of $response is NotifyMessageResponse $response = $client->notifyString([ 'topic' => 'topicB', 'key' => 'my-key', 'data' => '{}', ]);
Watcher
use Miczone\Wrapper\MiczoneEventBusClient\Watcher; use Miczone\Wrapper\MiczoneEventBusClient\WatcherHandler\StringWatcherHandlerInterface; $client = new Watcher([ 'hosts' => '127.0.0.1:1234', 'clientId' => 'my-service', 'groupId' => 'my-group', 'topics' => 'topicA,topicB' ]); /** * Handler interface can be: * - BooleanWatcherHandlerInterface * - IntegerWatcherHandlerInterface * - DoubleWatcherHandlerInterface * - StringWatcherHandlerInterface */ $client->setHandler(new class implements StringWatcherHandlerInterface { public function onMessage(string $topic, int $partition, int $offset, int $timestamp, string $key = null, string $data = null) { // Do your stuff } public function onError($code, string $message, \Exception $exception = null) { // Catch error } }); $client->start();
统计信息
- 总下载量: 276
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2021-01-05