sync_engine
sync_engine
¶
SyncEngine — checkpoint/resume orchestration for connector syncs.
Wraps IngestionPipeline with a lightweight SQLite state database so that
long-running syncs can be interrupted and resumed from the last saved cursor.
Typical usage::
store = KnowledgeStore(db_path=":memory:")
pipeline = IngestionPipeline(store)
engine = SyncEngine(pipeline)
items = engine.sync(connector) # first run
items = engine.sync(connector) # resumes from saved cursor
cp = engine.get_checkpoint(connector.connector_id)
Classes¶
SyncEngine
¶
SyncEngine(pipeline: IngestionPipeline, *, state_db: str = '')
Orchestrate connector syncs with checkpoint/resume tracking.
| PARAMETER | DESCRIPTION |
|---|---|
pipeline
|
The
TYPE:
|
state_db
|
Path to the SQLite database used for checkpoint state. If empty,
defaults to
TYPE:
|
Source code in src/openjarvis/connectors/sync_engine.py
Functions¶
sync
¶
sync(connector: BaseConnector, *, cancel_event: Optional[Event] = None) -> int
Run a full sync for connector and return the number of items ingested.
Resumes from the last saved cursor if one exists. Documents are batched in groups of 100 before being handed to the pipeline; a checkpoint is saved after every batch and once more at the end.
On error the checkpoint is updated with the error message and the exception is re-raised so callers can handle it.
Source code in src/openjarvis/connectors/sync_engine.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
close
¶
get_checkpoint
¶
Return the last checkpoint, or None if never synced.
Source code in src/openjarvis/connectors/sync_engine.py
reset_checkpoint
¶
Clear the saved checkpoint for connector_id.
Must be called whenever a connector is reconfigured to point at a
different underlying data source (e.g. disconnect/reconnect with a
new Obsidian vault path). Without this, the next sync would resume
from the old source's cursor/since watermark, inflating
items_synced with the old source's count and potentially
skipping new items whose timestamps predate that watermark.
Source code in src/openjarvis/connectors/sync_engine.py
restore_checkpoint
¶
Restore an exact checkpoint snapshot after a failed cleanup.