fix: try to partition apiroll query

This commit is contained in:
yanlong.wang 2025-04-01 18:28:48 +08:00
parent 0238d26984
commit 4498af7280
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37
2 changed files with 4 additions and 4 deletions

View File

@ -258,7 +258,7 @@ export class CrawlerHost extends RPCHost {
throw new InsufficientBalanceError(`Account balance not enough to run this query, please recharge.`); throw new InsufficientBalanceError(`Account balance not enough to run this query, please recharge.`);
} }
const rateLimitPolicy = auth.getRateLimits(rpcReflect.name.toUpperCase()) || [ const rateLimitPolicy = auth.getRateLimits('CRAWL') || [
parseInt(user.metadata?.speed_level) >= 2 ? parseInt(user.metadata?.speed_level) >= 2 ?
RateLimitDesc.from({ RateLimitDesc.from({
occurrence: 2000, occurrence: 2000,
@ -271,7 +271,7 @@ export class CrawlerHost extends RPCHost {
]; ];
const apiRoll = await this.rateLimitControl.simpleRPCUidBasedLimit( const apiRoll = await this.rateLimitControl.simpleRPCUidBasedLimit(
rpcReflect, uid, [rpcReflect.name.toUpperCase()], rpcReflect, uid, ['CRAWL'],
...rateLimitPolicy ...rateLimitPolicy
); );
@ -287,7 +287,7 @@ export class CrawlerHost extends RPCHost {
} }
}); });
} else if (ctx.ip) { } else if (ctx.ip) {
const apiRoll = await this.rateLimitControl.simpleRpcIPBasedLimit(rpcReflect, ctx.ip, [rpcReflect.name.toUpperCase()], const apiRoll = await this.rateLimitControl.simpleRpcIPBasedLimit(rpcReflect, ctx.ip, ['CRAWL'],
[ [
// 20 requests per minute // 20 requests per minute
new Date(Date.now() - 60 * 1000), 20 new Date(Date.now() - 60 * 1000), 20

@ -1 +1 @@
Subproject commit 492ed4cac38958c3715013da49a9e73b1d1ef8cb Subproject commit 9a04a66d10635bd4e5f46123fc2b59ec802bf3b7