Background Processor ==================== The Background Processor continuously polls the Redis transaction buffer and executes transactions against the main database. .. contents:: Table of Contents :local: :depth: 2 Core Implementation ------------------- Key code from ``background_processor.py``: .. literalinclude:: ../../../ccat_ops_db_api/transaction_buffering/background_processor.py :language: python :lines: 19-100 :emphasize-lines: 10-20, 71-80 Processing Loop --------------- 1. **Check buffer size** (LLEN) 2. **Check database connectivity** 3. **Pop transaction** (RPOP) 4. **Execute transaction** on main database 5. **Capture LSN** after commit 6. **Track replication** via LSN tracker 7. **Cleanup or extend cache** based on replication Configuration ------------- .. code-block:: bash BACKGROUND_PROCESSING_INTERVAL=1.0 # seconds TRANSACTION_RETRY_ATTEMPTS=3 TRANSACTION_RETRY_DELAY=5 # seconds Health Monitoring ----------------- The processor reports health via ``/health`` endpoint: .. code-block:: json { "background_processor": { "status": "running", "last_run": "2025-01-01T00:00:05Z", "transactions_processed": 150 } } Next Steps ---------- * :doc:`lsn-tracking` - How replication is tracked * :doc:`../../development/debugging-buffering` - Troubleshooting