Skip to content

Commit

Permalink
add types
Browse files Browse the repository at this point in the history
  • Loading branch information
sashankaryal committed Nov 22, 2024
1 parent ef43f81 commit c869b1c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/packages/looker/src/worker/pooled-fetch.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { fetchWithLinearBackoff } from "./decorated-fetch";

interface QueueItem {
request: {
url: string;
options?: RequestInit;
};
resolve: (value: Response | PromiseLike<Response>) => void;
reject: (reason?: any) => void;
}

// note: arbitrary number that seems to work well
const MAX_CONCURRENT_REQUESTS = 100;

let activeRequests = 0;
const requestQueue = [];
const requestQueue: QueueItem[] = [];

export const enqueueFetch = (request: {
url: string;
Expand Down Expand Up @@ -33,6 +42,5 @@ const processFetchQueue = () => {
.catch((error) => {
activeRequests--;
reject(error);
processFetchQueue();
});
};

0 comments on commit c869b1c

Please sign in to comment.