Skip to content

Commit

Permalink
Merge branch '1.x'
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.json
  • Loading branch information
chaz6chez committed Apr 1, 2024
2 parents 79ddef7 + f714bcd commit 96b450b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: CI
on:
push:
branches: [ "main" ]
branches: [ "1.x" ]
pull_request:
branches: [ "main" ]
branches: [ "1.x" ]

jobs:
PHPUnit:
Expand Down
30 changes: 15 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
"description": "Webman plugin workbunny/webman-push-server",
"authors": [
{
"name": "chaz6chez",
"email": "[email protected]",
"homepage": "http://chaz6chez.cn"
"name": "chaz6chez",
"email": "[email protected]",
"homepage": "http://chaz6chez.cn"
}
],
"support": {
"issues": "https://github.com/workbunny/webman-push-server/issues",
"source": "https://github.com/workbunny/webman-push-server"
},
"require": {
"php": ">=8.0",
"ext-json": "*",
"ext-redis": "*",
"workerman/http-client": "^1.0 | ^2.0",
"workerman/channel": "^1.0",
"webman/console": "^1.0",
"psr/container": "^1.0 | ^2.0",
"illuminate/redis": "^9.0|^10.0",
"illuminate/database": "^9.0|^10.0",
"illuminate/events": "^9.0|^10.0",
"monolog/monolog": "^2.0 | ^3.0",
"pusher/pusher-php-server": "^7.2"
"php": ">=8.0",
"ext-json": "*",
"ext-redis": "*",
"workerman/http-client": "^1.0 | ^2.0",
"workerman/channel": "^1.0",
"webman/console": "^1.0",
"psr/container": "^1.0 | ^2.0",
"illuminate/redis": "^9.0|^10.0",
"illuminate/database": "^9.0|^10.0",
"illuminate/events": "^9.0|^10.0",
"monolog/monolog": "^2.0 | ^3.0",
"pusher/pusher-php-server": "^7.2"
},
"require-dev": {
"workerman/webman-framework": "^1.5",
Expand Down
24 changes: 16 additions & 8 deletions src/HookServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ public function ack(string $queue, string $group, array $idArray): bool
*/
public function claim(string $queue, string $group, string $consumer): void
{
if (!method_exists(self::getStorage(), 'xAutoClaim')) {
Log::channel('plugin.workbunny.webman-push-server.warning')->warning(
'Method xAutoClaim requires redis-server >= 6.2.0. '
);
return;
}
try {
if ($idArray = self::getStorage()->xAutoClaim(
$queue, $group, $consumer,
Expand Down Expand Up @@ -252,13 +258,15 @@ protected function _tempInit(): void
// 创建数据库结构
$builder = Db::schema('plugin.workbunny.webman-push-server.local-storage');
if (!$builder->hasTable('temp')) {
$builder->create('temp', function (Blueprint $table) {
$table->id();
$table->string('queue');
$table->json('data');
$table->integer('create_at');
});
echo 'local-storage db created. ' . PHP_EOL;
try {
$builder->create('temp', function (Blueprint $table) {
$table->id();
$table->string('queue');
$table->json('data');
$table->integer('create_at');
});
echo 'local-storage db created. ' . PHP_EOL;
} catch (Throwable $throwable) {}
}
}
}
Expand Down Expand Up @@ -311,7 +319,7 @@ function () {
$interval = self::getConfig('claim_interval', 0);
if ($interval > 0) {
$this->_claimTimer = Timer::add(
self::getConfig('claim_interval'),
$interval,
function () use ($queue, $group, $consumer) {
$this->claim($queue, $group, $consumer);
}
Expand Down
4 changes: 4 additions & 0 deletions src/WebhookHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public function run(string $queue, string $group, array $dataArray)
{
$idArray = array_keys($dataArray);
$messageArray = array_values($dataArray);
// 如果没有配置webhook地址,直接ack
if (!HookServer::getConfig('webhook_url')) {
HookServer::instance()->ack($queue, $group, $idArray);
}
// http发送
$this->_request($method = 'POST', [
'header' => [
Expand Down

0 comments on commit 96b450b

Please sign in to comment.