Skip to content

Commit

Permalink
feat: 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
roiwk committed Jan 9, 2025
1 parent 20bf5a5 commit c006497
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 366 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ rabbitmq 是一个异步(workerman)和同步的PHP客户端,用于异步

# Dependencies 依赖

php >= 8.0
|Version Tag|Dependencies|
|-----|---|
|^v1.0| php >=8.0 workerman >= 4.0|
|^v2.0| php >=8.1 workerman >= 5.0|

# Install 安装

Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"php": "^8.0",
"psr/log": "^1.0||^2.0||^3.0",
"illuminate/collections": "^8.0|^9.0|^10.0",
"bunny/bunny": "^0.5.5"
"bunny/bunny": "^0.5.5",
"workerman/rabbitmq": "^2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -30,6 +31,7 @@
},
"require-dev": {
"monolog/monolog": "^2.0|^3.0",
"workerman/workerman": "^4.0|^5.0@beta"
"workerman/workerman": "^5.0",
"revolt/event-loop": "^1.0"
}
}
1 change: 1 addition & 0 deletions examples/1-hello-world/receive-async.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}

$worker = new Worker();
$worker->eventLoop = \Workerman\Events\Revolt::class;

$config = require __DIR__ . '/../config.php';
$log = require __DIR__ . '/../log.php';
Expand Down
8 changes: 5 additions & 3 deletions examples/1-hello-world/send-async.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@
require __DIR__ . '/../../vendor/autoload.php';
}

$worker = new Worker();
// $_ENV['REVOLT_DRIVER'] = \Revolt\EventLoop\Driver\StreamSelectDriver::class;

$worker = new Worker();
// $worker->eventLoop = \Workerman\Events\Revolt::class;
// $worker->count = 4;

$worker->onWorkerStart = function() {

$config = require __DIR__ . '/../config.php';
$log = require __DIR__ . '/../log.php';

// Timer::add(1, function() use ($config, $log) {
Timer::add(1, function() use ($config, $log) {
Producer::connect($config, $log)->publishAsync('Hello World!', '', '', 'hello');
// });
});
};
Worker::runAll();
4 changes: 3 additions & 1 deletion examples/1-hello-world/send.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
$config = require __DIR__ . '/../config.php';
$log = require __DIR__ . '/../log.php';

Producer::connect($config, $log)->publishSync('Hello World!', '', '', 'hello');
// for ($i = 0; $i < 10; $i++) {
Producer::connect($config, $log)->publishSync('Hello World!', '', '', 'hello');
// }

echo " [x] Sent 'Hello World!'\n";

2 changes: 1 addition & 1 deletion examples/config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

return [
'host' => '127.0.0.1',
'host' => '172.16.30.222',
'port' => 5672,
'vhost' => '/',
'mechanism' => 'AMQPLAIN',
Expand Down
Loading

0 comments on commit c006497

Please sign in to comment.