Copy-and-Paste: 2. Implement Basic Copy-and-Paste Task
⚠️ Important: Use the /feature/copy-and-paste branch as the base branch for this feature.
Covers Development Plan Point: 2
Note: The interface definitions below are an initial draft and are open for discussion and refinement once development begins.
Description:
This task focuses on implementing the core logic for a "Copy-and-Paste" operation as a task managed by the Task Engine. This initial version will have basic functionality and error handling.
Requirements:
-
Task Implementation:
- Create a
CopyPasteCollectionTask class that implements the Task interface from the Task Engine.
-
Configuration:
-
Connection Handling:
- Utilize
connectionId to work with existing connection management, supporting various authentication methods.
- Network resilience is handled by the existing
Connection class and is out of scope for this task. The task should abort with an error if the connection cannot be recovered.
-
Data Transfer Mechanism:
- Implement a buffer-based streaming approach:
- One asynchronous operation reads documents from the source collection into an in-memory buffer. It should pause reading if the buffer is full.
- Another asynchronous operation reads documents from the buffer and writes them to the target collection using bulk operations (e.g., MongoDB
insertMany).
- This approach aims to manage memory efficiently.
-
Database-Agnostic Design:
-
Initial Count for Progress:
- The task initialization phase should run a count operation on the source collection to determine the total number of documents to be copied. This will be used for progress reporting.
-
Basic Testing:
- Implement basic Jest tests for the
CopyPasteCollectionTask to be run on demand.
Acceptance Criteria:
CopyPasteCollectionTask can successfully copy all documents from a source collection to a target collection on the same or different servers (using provided DocumentReader and DocumentWriter).
- The task correctly reports its status (
pending, initializing (counting), running, completed, failed) via the Task Engine.
- The task aborts if any error occurs during reading or writing in this basic version (respecting
ConflictResolutionStrategy.Abort).
- Memory usage is managed by the buffer-based streaming approach.
- Basic unit tests pass.
Dependencies:
- Copy-and-Paste: 1. Implement Core Task Engine
Copy-and-Paste: 2. Implement Basic Copy-and-Paste Task
Covers Development Plan Point: 2
Note: The interface definitions below are an initial draft and are open for discussion and refinement once development begins.
Description:
This task focuses on implementing the core logic for a "Copy-and-Paste" operation as a task managed by the Task Engine. This initial version will have basic functionality and error handling.
Requirements:
Task Implementation:
CopyPasteCollectionTaskclass that implements theTaskinterface from the Task Engine.Configuration:
The task should accept a configuration object with:
Source:
connectionId,databaseName,collectionName.Target:
connectionId,databaseName,collectionName(ornewCollectionName).Conflict Resolution: A basic configuration, initially hardcoded to 'abort' on any error or conflict.
Connection Handling:
connectionIdto work with existing connection management, supporting various authentication methods.Connectionclass and is out of scope for this task. The task should abort with an error if the connection cannot be recovered.Data Transfer Mechanism:
insertMany).Database-Agnostic Design:
The
CopyPasteCollectionTaskshould be database-type-agnostic. It will be constructed with database-specific reader and writer components.Define interfaces for these components:
Initial Count for Progress:
Basic Testing:
CopyPasteCollectionTaskto be run on demand.Acceptance Criteria:
CopyPasteCollectionTaskcan successfully copy all documents from a source collection to a target collection on the same or different servers (using providedDocumentReaderandDocumentWriter).pending,initializing(counting),running,completed,failed) via the Task Engine.ConflictResolutionStrategy.Abort).Dependencies: