From f915a23bbd9c0ee18c7f0683f7abea28556acea9 Mon Sep 17 00:00:00 2001 From: zyimm Date: Sun, 9 Jul 2023 18:54:29 +0800 Subject: [PATCH] =?UTF-8?q?style:=E7=B1=BB=E5=9E=8B=E7=BA=A6=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.php | 7 ++++--- src/connection/Config.php | 25 ++++++++++--------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/config.php b/src/config.php index c49cb7c..e8d615f 100644 --- a/src/config.php +++ b/src/config.php @@ -1,8 +1,9 @@ env('mq_host', 'http://192.168.21.170:8085'), - 'callback' => '/rocketmq/producer/notify', - 'subscribe' => [ + 'host' => env('mq_host', 'http://192.168.21.170:8085'), + 'callback_host' => env('mq_callback_host', 'http://192.168.21.170:8085'), + 'callback' => '/rocketmq/producer/notify', + 'subscribe' => [ ] ]; diff --git a/src/connection/Config.php b/src/connection/Config.php index 81ee372..6767571 100644 --- a/src/connection/Config.php +++ b/src/connection/Config.php @@ -12,9 +12,9 @@ class Config public function __construct(array $configs = []) { - foreach ($configs as $key => $val){ - if(method_exists($key, $this)){ - call_user_func([$this, $key], $val); + foreach ($configs as $key => $val) { + if (method_exists($key, $this)) { + call_user_func([$this, $key], $val); } } } @@ -28,36 +28,31 @@ class Config } /** - * @param mixed $host + * @param string $host */ - public function setHost($host): void + public function setHost(string $host): void { $this->host = $host; } /** - * @return mixed + * @return int */ public function getTimeOut() { - return $this->timeOut; + return $this->timeOut ?? 60; } /** - * @param mixed $timeOut + * @param int $timeOut */ - public function setTimeOut($timeOut): void + public function setTimeOut(int $timeOut): void { $this->timeOut = $timeOut; } - public function getProducerUrl(): string - { - return $this->getHost().'notifyUsing'; - } - public function getBackUrl(): string { - return $this->getHost().config('rocket_mq.callback'); + return config('rocket_mq.callback_host').config('rocket_mq.callback'); } } \ No newline at end of file