The TransactionManagerInterface abstracts transaction boundaries around
chunk writes.
namespace Lemric\BatchProcessing\Transaction;
interface TransactionManagerInterface
{
public function begin(): void;
public function commit(): void;
public function rollback(): void;
}Wraps PDO native transactions:
use Lemric\BatchProcessing\Transaction\PdoTransactionManager;
$txManager = new PdoTransactionManager($pdo);A no-op implementation for environments without a database (in-memory processing, tests):
use Lemric\BatchProcessing\Transaction\ResourcelessTransactionManager;
$txManager = new ResourcelessTransactionManager();txManager->begin()
writer->write(chunk)
txManager->commit() ← success
txManager->begin()
writer->write(chunk)
txManager->rollback() ← failure → scan mode
On failure, the framework enters scan mode: each item is written in its own transaction to isolate the failing one.