From a044e2dfcc80e08089f49d54962510e1a1324bb1 Mon Sep 17 00:00:00 2001 From: chaz6chez Date: Fri, 12 Apr 2024 17:19:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0publish=20enable=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E6=8E=A7=E5=88=B6publish=E7=9A=84=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=85=A5=E9=98=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/HookServer.php | 3 +++ .../plugin/workbunny/webman-push-server/app.php | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/HookServer.php b/src/HookServer.php index bc4061a..09ef0a1 100644 --- a/src/HookServer.php +++ b/src/HookServer.php @@ -101,6 +101,9 @@ public static function sign(string $secret, string $method, array $query, string */ public function publish(string $event, array $data, ?string $republishCountKey = null): ?bool { + if (!self::getConfig('publish_enable', true)) { + return null; + } $queue = self::getConfig('queue_key'); $queueLimit = self::getConfig('queue_limit', 0); $value = [ diff --git a/src/config/plugin/workbunny/webman-push-server/app.php b/src/config/plugin/workbunny/webman-push-server/app.php index ddce68b..23a5cab 100644 --- a/src/config/plugin/workbunny/webman-push-server/app.php +++ b/src/config/plugin/workbunny/webman-push-server/app.php @@ -11,6 +11,7 @@ */ declare(strict_types=1); +use Workbunny\WebmanPushServer\DefaultHandler; use Workbunny\WebmanPushServer\WebhookHandler; use const Workbunny\WebmanPushServer\PUSH_SERVER_EVENT_CHANNEL_OCCUPIED; use const Workbunny\WebmanPushServer\PUSH_SERVER_EVENT_CHANNEL_VACATED; @@ -50,6 +51,8 @@ ], // hook消费者配置 'hook-server' => [ + // 开关 + 'publish_enable' => true, // false时 所有事件不会被publish // redis通道 'redis_channel' => 'default', // 队列名 @@ -60,11 +63,13 @@ // 消息重入队列定时间隔 'requeue_interval' => 5 * 60, // 0为不进行消息重入队列的处理 s // 事件消费相关 - 'consumer_interval' => 1, // 消费间隔 ms - 'prefetch_count' => 5, // 每次消费者消费的最大数量 + 'consumer_interval' => 100, // 消费间隔 ms + 'prefetch_count' => 20, // 每次消费者消费的最大数量 'queue_limit' => 0, // 队列长度限制,0为不限制 - // 事件处理器 - 'hook_handler' => WebhookHandler::class, + // 默认事件处理器 + 'hook_handler' => DefaultHandler::class, +// // webhook回调事件处理器 +// 'hook_handler' => WebhookHandler::class, // webhook相关配置 'webhook_url' => 'http://127.0.0.1:8002/webhook', // 样例接口 'webhook_secret' => 'YOUR_WEBHOOK_SECRET', // 样例