Problem
In poc-sync-engine/src/SyncManager.ts, processing queue items depends on a hardcoded mock API call:
private async mockFrappeApiCall(job: SyncJob): Promise<void> {
// Hardcoded simulation
}
This tightly couples queue orchestration with a mock transport implementation, making it difficult to integrate real HTTP clients or reuse SyncManager across environments.
Proposed Solution
- Define a pluggable
SyncHandler interface that accepts a SyncJob and processes it:
export interface SyncHandler {
handle(job: SyncJob): Promise<void>;
}
Note: The initial interface can remain minimal, while still allowing future implementations to extend sync result handling or retry behavior without coupling execution logic directly to SyncManager.
- Modify the
SyncManager constructor to accept this interface:
export class SyncManager {
private queue: SyncQueue;
private handler: SyncHandler;
...
constructor(queue: SyncQueue, handler: SyncHandler) {
this.queue = queue;
this.handler = handler;
}
}
- Delegate sync execution in
drainQueue() to this.handler.handle(job) instead of the private mock helper.
- Error propagation and retry behavior should remain controlled by
SyncManager, while execution details remain delegated to the injected handler.
Acceptance Criteria
Problem
In poc-sync-engine/src/SyncManager.ts, processing queue items depends on a hardcoded mock API call:
This tightly couples queue orchestration with a mock transport implementation, making it difficult to integrate real HTTP clients or reuse
SyncManageracross environments.Proposed Solution
SyncHandlerinterface that accepts aSyncJoband processes it:SyncManager.SyncManagerconstructor to accept this interface:drainQueue()tothis.handler.handle(job)instead of the private mock helper.SyncManager, while execution details remain delegated to the injected handler.Acceptance Criteria
SyncManagerhas no hardcoded mock API client call inside.SyncManagersupports interchangeable handler implementations (e.g., mock or HTTP-backed handlers).SyncHandlerinstance.