Synchronization Layer
The Synchronization Layer orchestrates the continuous delivery of database event payloads into target vector databases. It handles batch processing, operation compaction, retries, and error routing.
Module Summary
Coordinates database-to-vector synchronization. |
|
Thread-safe Dead Letter Queue (DLQ) to hold failed events. |
|
Configuration for exponential backoff retries with jitter. |
API Reference
Synchronization manager coordinating event propagation to vector store adapters.
- class DeadLetterQueue(max_size=1000)[source]
Bases:
objectThread-safe Dead Letter Queue (DLQ) to hold failed events.
- Parameters:
max_size (int)
- __init__(max_size=1000)[source]
Initialises the DeadLetterQueue.
- Parameters:
max_size (int) – Maximum number of events to hold in the queue. A max_size <= 0 means infinite size.
- Return type:
None
- put(event, exception)[source]
Add a failed event and its causing exception to the DLQ.
If the queue is full, the event is dropped and a warning is logged.
- Parameters:
event (DebeziumEventModel) – The DebeziumEventModel that failed to sync.
exception (Exception) – The Exception raised during synchronization.
- Return type:
None
- class RetryConfig(max_retries=3, initial_delay=1.0, backoff_factor=2.0, jitter=True)[source]
Bases:
objectConfiguration for exponential backoff retries with jitter.
- class SyncManager(document_builder, vector_store_adapter, soft_delete=False, retry_config=None, dlq=None, max_workers=None)[source]
Bases:
objectCoordinates database-to-vector synchronization.
Converts DebeziumEventModels using a DocumentBuilder and propagates updates/deletes to a VectorStoreAdapter.
- Parameters:
document_builder (DocumentBuilder)
vector_store_adapter (VectorStoreAdapter)
soft_delete (bool)
retry_config (RetryConfig | None)
dlq (DeadLetterQueue | None)
max_workers (int | None)
- __init__(document_builder, vector_store_adapter, soft_delete=False, retry_config=None, dlq=None, max_workers=None)[source]
Initialises the SyncManager.
- Parameters:
document_builder (DocumentBuilder) – Builder to map Debezium events to LangChain Documents.
vector_store_adapter (VectorStoreAdapter) – Destination vector store backend.
soft_delete (bool) – If True, delete operations update metadata with _is_deleted=True instead of hard-deleting the document.
retry_config (RetryConfig | None) – Settings for transient error retries.
dlq (DeadLetterQueue | None) – Optional DeadLetterQueue to capture failed events.
max_workers (int | None) – Maximum number of worker threads for parallel document building.
- Return type:
None
- sync(event)[source]
Synchronise a Debezium change event to the vector store.
If synchronization fails after all retry attempts, the event is redirected to the DeadLetterQueue (DLQ).
- Parameters:
event (DebeziumEventModel) – The parsed, canonical Debezium event.
- Return type:
None
- sync_batch(events)[source]
Synchronise a batch of Debezium change events to the vector store.
Compacts the batch by doc_id to only apply the final state of each record. If the batch synchronization fails after all retry attempts, it falls back to sequential synchronization to isolate and route failing events to the DLQ.
- Parameters:
events (list[DebeziumEventModel])
- Return type:
None