Perf: offload Telegram CIDR fetching into separate thread

This commit is contained in:
SukkaW
2025-12-10 16:31:15 +08:00
parent f41bb4a3b8
commit 6a35d3e4a6
7 changed files with 174 additions and 148 deletions

View File

@@ -3,6 +3,7 @@ import { SHARED_DESCRIPTION } from './constants/description';
import { RulesetOutput } from './lib/rules/ruleset';
import Worktank from 'worktank';
import { RULES } from './constants/microsoft-cdn';
import { wait } from 'foxts/wait';
const pool = new Worktank({
pool: {
@@ -47,10 +48,10 @@ const pool = new Worktank({
}
});
export const getMicrosoftCdnRulesetPromise = pool.exec(
export const getMicrosoftCdnRulesetPromise = wait(0).then(() => pool.exec(
'getMicrosoftCdnRuleset',
[__filename]
).finally(() => pool.terminate());
)).finally(() => pool.terminate());
export const buildMicrosoftCdn = task(require.main === module, __filename)(async (span) => {
const [domains, domainSuffixes] = await span.traceChildPromise('get microsoft cdn domains', getMicrosoftCdnRulesetPromise);