作者 lackoxygen

feat

... ... @@ -23,7 +23,11 @@
},
"require": {
"php": ">=7.4",
"wujunze/dingtalk-exception": "^2.2"
"wujunze/dingtalk-exception": "^2.2",
"illuminate/queue":"^8.0",
"illuminate/support": "^8.0",
"illuminate/bus": "^8.0",
"monolog/monolog": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5.10",
... ...
<?php
use Lackoxygen\ExceptionPush\Agents\{Ding, Wx};
use Lackoxygen\ExceptionPush\Agents\Ding;
use Lackoxygen\ExceptionPush\Agents\Wx;
return [
'agents' => [
... ... @@ -12,10 +13,10 @@ return [
],
'client' => [
'timeout' => 30.00,
'timeout' => 5.00,
],
'callbacks' => [
'formatter' => null, 'dispatcher' => null
'formatter' => null, 'dispatcher' => 'Lackoxygen\ExceptionPush\Job::push'
]
];
... ...
... ... @@ -30,8 +30,7 @@ class Dispatcher implements CallbackInterface
}
try {
$agent->report($body);
} catch (\Exception $exception) {
app('log')->error($exception->getMessage());
} catch (\Throwable $exception) {
}
}
};
... ...
<?php
namespace Lackoxygen\ExceptionPush\Job;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Lackoxygen\ExceptionPush\Dispatcher;
class ExceptionPushJob implements ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
protected array $agents;
protected array $traces;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(array $agents, array $traces)
{
$this->agents = $agents;
$this->traces = $traces;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$dispatcher = new Dispatcher();
$callback = $dispatcher->default();
$callback($this->agents, $this->traces);
}
public static function push()
{
static::dispatch(...func_get_args());
}
}
... ...