taolib.testing.data_sync.repository.checkpoint_repo#

同步检查点 Repository。

提供 Checkpoint 的 MongoDB 持久化操作。

Classes#

CheckpointRepository

同步检查点 Repository。

Module Contents#

class taolib.testing.data_sync.repository.checkpoint_repo.CheckpointRepository(collection: motor.motor_asyncio.AsyncIOMotorCollection)#

Bases: taolib.testing._base.repository.AsyncRepository[taolib.testing.data_sync.models.checkpoint.SyncCheckpoint]

同步检查点 Repository。

async get_or_create(job_id: str, collection_name: str) taolib.testing.data_sync.models.checkpoint.SyncCheckpoint#

获取或创建检查点。

参数:
  • job_id -- 作业 ID

  • collection_name -- 集合名称

返回:

检查点文档

async update_checkpoint(job_id: str, collection_name: str, last_ts: datetime.datetime, last_id: str, count: int) taolib.testing.data_sync.models.checkpoint.SyncCheckpoint | None#

更新检查点。

参数:
  • job_id -- 作业 ID

  • collection_name -- 集合名称

  • last_ts -- 最后同步时间戳

  • last_id -- 最后同步文档 ID

  • count -- 本次同步文档数

返回:

更新后的检查点文档,如果不存在则返回 None

async delete_by_job(job_id: str) int#

删除指定作业的所有检查点。

参数:

job_id -- 作业 ID

返回:

删除的检查点数量

async create_indexes() None#

创建索引。