diff --git a/src/proxyScripts/proxy.js b/src/proxyScripts/proxy.js index 6f06b9f..c4a21ba 100644 --- a/src/proxyScripts/proxy.js +++ b/src/proxyScripts/proxy.js @@ -25,9 +25,8 @@ * * Structure: * Section 1: Authentication (Service Account JWT) - * Section 2: Request Queue (FIFO) - * Section 3: Drive API Client - * Section 4: Request Handling & Routing + * Section 2: Drive API Client + * Section 3: Request Handling & Routing * * @module proxy */ @@ -104,58 +103,7 @@ async function getAccessTokenCached() { } // ============================================================================= -// Section 2: Request Queue (FIFO) -// ============================================================================= - -/** - * FIFO Queue for sequential request processing - * Prevents concurrent Drive API operations per specification - */ -class RequestQueue { - constructor() { - this.queue = []; - this.processing = false; - } - - async enqueue(handler) { - return new Promise((resolve, reject) => { - this.queue.push({ handler, resolve, reject }); - if (!this.processing) this._processNext(); - }); - } - - async _processNext() { - if (this.queue.length === 0) { - this.processing = false; - return; - } - - this.processing = true; - const { handler, resolve, reject } = this.queue.shift(); - - try { - resolve(await handler()); - } catch (error) { - reject(error); - } finally { - this._processNext(); - } - } - - get length() { - return this.queue.length; - } - - get isProcessing() { - return this.processing; - } -} - -// Singleton instance -const requestQueue = new RequestQueue(); - -// ============================================================================= -// Section 3: Drive API Client +// Section 2: Drive API Client // ============================================================================= /** @@ -214,11 +162,11 @@ async function queryDocuments(options = {}) { } // ============================================================================= -// Section 4: Request Handling & Routing +// Section 3: Request Handling & Routing // ============================================================================= /** - * Handle sitemap generation request (wrapped in FIFO queue) + * Handle sitemap generation request */ async function handleSitemapRequest(res, requestId) { try { @@ -275,9 +223,9 @@ async function handleSitemapRequest(res, requestId) { return; } - // Handle sitemap route with FIFO queue (sequential processing) + // Handle sitemap route if (routeResult.route === "sitemap") { - await requestQueue.enqueue(() => handleSitemapRequest(res, requestId)); + await handleSitemapRequest(res, requestId); return; } } catch (error) {