fix: isolate tick errors per event, bound overlap lock
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
This commit is contained in:
@@ -17,7 +17,9 @@ use App\Scheduling\WindowResolver;
|
||||
use Illuminate\Contracts\Cache\Repository as Cache;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Один тик планировщика (раз в минуту): переходы состояний по датам и решение,
|
||||
@@ -39,7 +41,15 @@ final class Tick
|
||||
Event::query()
|
||||
->whereIn('state', EventState::nonTerminalValues())
|
||||
->with('user')
|
||||
->chunkById(200, fn (Collection $events) => $events->each(fn (Event $e) => $this->process($e)));
|
||||
->chunkById(200, function (Collection $events) {
|
||||
foreach ($events as $event) {
|
||||
try {
|
||||
$this->process($event);
|
||||
} catch (Throwable $e) {
|
||||
Log::error('hado.tick: событие пропущено', ['event_id' => $event->id, 'error' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private function process(Event $event): void
|
||||
|
||||
Reference in New Issue
Block a user