From e570e3bbff7ab3eafbd971c9e44df747809794f4 Mon Sep 17 00:00:00 2001 From: alikia2x Date: Mon, 10 Feb 2025 21:42:32 +0800 Subject: [PATCH] add: task specified request for NetScheduler --- lib/mq/scheduler.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/mq/scheduler.ts b/lib/mq/scheduler.ts index 7b36940..24fce04 100644 --- a/lib/mq/scheduler.ts +++ b/lib/mq/scheduler.ts @@ -4,9 +4,6 @@ import {RateLimiter} from "lib/mq/rateLimiter.ts"; interface Proxy { type: string; task: string; - data?: { - [key: string]: string; - }; limiter?: RateLimiter; } @@ -56,11 +53,12 @@ export class NetScheduler { * - The native `fetch` function threw an error: with error code FETCH_ERROR * - The proxy type is not supported: with error code NOT_IMPLEMENTED */ - async request(url: string, method: string = "GET"): Promise { + async request(url: string, method: string = "GET", task: string): Promise { // find a available proxy const proxiesNames = Object.keys(this.proxies); for (const proxyName of proxiesNames) { const proxy = this.proxies[proxyName]; + if (proxy.task !== task) continue; if (!proxy.limiter) { return await this.proxyRequest(url, proxyName, method); }