perf: separate task creation from processing to eliminate compilation overhead (#23485)
* refactor: separate task creation from processing to eliminate compilation overhead - Create TaskProcessor class to handle task processing logic - Move processQueue and cleanup methods to TaskProcessor - Remove task handler imports from InternalTasker creation path - Eliminate 2.5-3s compilation overhead by only loading task handlers during processing - Maintain existing tasker.create() API for all callers - Use composition pattern for clean separation of concerns Co-Authored-By: [email protected] <[email protected]> refactor: completely separate TaskProcessor from InternalTasker - Remove processQueue() and cleanup() methods from Tasker interface - Eliminate TaskProcessor dependency from InternalTasker class - Update API endpoints (cron.ts, cleanup.ts) to use TaskProcessor directly - Update README documentation to show correct TaskProcessor usage - Complete separation ensures task creation no longer imports task handlers - Eliminates 2.5-3s compilation overhead while preserving all functionality Co-Authored-By: [email protected] <[email protected]> * Moved the cleanup method back to internal tasker --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
9724bc07a6
commit
1739114490
5 files changed
+52
-39
No files matched your search
@@ -1,14 +1,15 @@
|
||||
import type { NextRequest } from "next/server";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import tasker from "..";
|
||||
import { TaskProcessor } from "../task-processor";
|
||||
|
||||
async function handler(request: NextRequest) {
|
||||
const authHeader = request.headers.get("authorization");
|
||||
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
|
||||
return new Response("Unauthorized", { status: 401 });
|
||||
}
|
||||
await tasker.processQueue();
|
||||
const processor = new TaskProcessor();
|
||||
await processor.processQueue();
|
||||
return NextResponse.json({ success: true });
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user