摆烂
This commit is contained in:
parent
d7c79a97d1
commit
45e32825cf
@ -3,7 +3,6 @@
|
||||
namespace App\Jobs\Module;
|
||||
|
||||
use App\Events\ServerEvent;
|
||||
use App\Exceptions\ModuleRequestException;
|
||||
use App\Models\Module;
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use Illuminate\Bus\Queueable;
|
||||
@ -11,6 +10,7 @@
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class FetchModule implements ShouldQueue
|
||||
@ -51,8 +51,8 @@ public function handle()
|
||||
foreach ($modules as $module) {
|
||||
try {
|
||||
$response = $module->http()->get('remote');
|
||||
} catch (ModuleRequestException $e) {
|
||||
Log::error('无法连接到模块:' . $module->name, ['error', $e->getMessage()]);
|
||||
} catch (ConnectException $e) {
|
||||
Log::error($e->getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Exceptions\ModuleRequestException;
|
||||
use Exception;
|
||||
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
@ -177,16 +175,9 @@ public function check($module_id = null): bool
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ModuleRequestException
|
||||
*/
|
||||
public function http(): PendingRequest
|
||||
{
|
||||
try {
|
||||
return Http::module($this->api_token, $this->url)->acceptJson()->timeout(5);
|
||||
} catch (Exception $e) {
|
||||
throw new ModuleRequestException($e->getMessage());
|
||||
}
|
||||
return Http::module($this->api_token, $this->url)->acceptJson();
|
||||
}
|
||||
|
||||
#[ArrayShape(['transactions' => "array"])]
|
||||
|
Loading…
Reference in New Issue
Block a user