accept(inboxPage([], 'cursor-start'), 0, null); echo json_encode(['checkpoint' => $inbox->checkpoint()], JSON_THROW_ON_ERROR); exit; } $db = inboxConnection(); $inbox = new WarehouseInbox($db, 'synthetic-sgc-a', 7, 99, 'reader'); if ($mode === 'hold') { $db->beginTransaction(); $db->query('SELECT version FROM sgc_exchange_streams FOR UPDATE')->fetchColumn(); echo 'locked'; flush(); usleep(1500000); $db->commit(); } if (! in_array($mode, ['hold', 'run', 'exit-after-commit'], true)) { throw new LogicException('Modo inválido.'); } $id = (int) ($argv[2] ?? 1); try { $result = $inbox->accept(inboxPage([inboxEvent($id)], 'cursor-'.$id), 1, 'cursor-start'); if ($mode === 'exit-after-commit') { exit(42); // committed, acknowledgement intentionally lost } echo json_encode(['result' => 'accepted', ...$result], JSON_THROW_ON_ERROR); } catch (RuntimeException $e) { echo json_encode(['result' => 'conflict'], JSON_THROW_ON_ERROR); }