| | |
| | | <?php |
| | | namespace JVBase\managers\queue; |
| | | use Throwable; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | | } |
| | |
| | | $op->result = $result->result; |
| | | $op->completedAt = current_time('mysql'); |
| | | |
| | | } catch (\Throwable $e) { |
| | | } catch (Throwable $e) { |
| | | error_log("[Processor] Exception caught: " . $e->getMessage()); |
| | | $this->handleFailure($op, $e); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | } catch (\Throwable $e) { |
| | | } catch (Throwable $e) { |
| | | error_log("[Processor] Chunk {$index} failed: " . $e->getMessage()); |
| | | |
| | | // Record failed items from this chunk |
| | |
| | | return $chunks; |
| | | } |
| | | |
| | | private function handleFailure(Operation $op, \Throwable $e): void |
| | | private function handleFailure(Operation $op, Throwable $e): void |
| | | { |
| | | $hash = md5($e->getMessage()); |
| | | |
| | |
| | | |
| | | $op->errorMessage = $e->getMessage(); |
| | | |
| | | JVB()->error()->log( |
| | | '[Queue]:processOne', |
| | | $e->getMessage(), |
| | | [ |
| | | 'operation_id' => $op->id, |
| | | 'type' => $op->type, |
| | | 'user_id' => $op->userId, |
| | | 'retries' => $op->retries, |
| | | ], |
| | | $op->outcome === 'failed_permanent' ? 'critical' : 'warning' |
| | | ); |
| | | // JVB()->error()->log( |
| | | // '[Queue]:processOne', |
| | | // $e->getMessage(), |
| | | // [ |
| | | // 'operation_id' => $op->id, |
| | | // 'type' => $op->type, |
| | | // 'user_id' => $op->userId, |
| | | // 'retries' => $op->retries, |
| | | // ], |
| | | // $op->outcome === 'failed_permanent' ? 'critical' : 'warning' |
| | | // ); |
| | | } |
| | | |
| | | private function calculateBackoff(int $attempt): string |