nomagick commited on
Commit
cda0f37
·
unverified ·
1 Parent(s): 0a2c093

feat: updated rate policy

Browse files
backend/functions/src/cloud-functions/crawler.ts CHANGED
@@ -644,10 +644,17 @@ ${suffixMixins.length ? `\n${suffixMixins.join('\n\n')}\n` : ''}`;
644
  throw new InsufficientBalanceError(`Account balance not enough to run this query, please recharge.`);
645
  }
646
 
647
- const rateLimitPolicy = auth.getRateLimits(rpcReflect.name.toUpperCase()) || [RateLimitDesc.from({
648
- occurrence: 200,
649
- periodSeconds: 60
650
- })];
 
 
 
 
 
 
 
651
 
652
  const apiRoll = await this.rateLimitControl.simpleRPCUidBasedLimit(
653
  rpcReflect, uid, [rpcReflect.name.toUpperCase()],
 
644
  throw new InsufficientBalanceError(`Account balance not enough to run this query, please recharge.`);
645
  }
646
 
647
+ const rateLimitPolicy = auth.getRateLimits(rpcReflect.name.toUpperCase()) || [
648
+ parseInt(user.metadata?.speed_level) >= 2 ?
649
+ RateLimitDesc.from({
650
+ occurrence: 1000,
651
+ periodSeconds: 60
652
+ }) :
653
+ RateLimitDesc.from({
654
+ occurrence: 200,
655
+ periodSeconds: 60
656
+ })
657
+ ];
658
 
659
  const apiRoll = await this.rateLimitControl.simpleRPCUidBasedLimit(
660
  rpcReflect, uid, [rpcReflect.name.toUpperCase()],
backend/functions/src/cloud-functions/searcher.ts CHANGED
@@ -109,10 +109,17 @@ export class SearcherHost extends RPCHost {
109
  throw new InsufficientBalanceError(`Account balance not enough to run this query, please recharge.`);
110
  }
111
 
112
- const rateLimitPolicy = auth.getRateLimits(rpcReflect.name.toUpperCase()) || [RateLimitDesc.from({
113
- occurrence: 40,
114
- periodSeconds: 60
115
- })];
 
 
 
 
 
 
 
116
 
117
  const apiRoll = await this.rateLimitControl.simpleRPCUidBasedLimit(
118
  rpcReflect, uid, [rpcReflect.name.toUpperCase()],
@@ -334,7 +341,7 @@ export class SearcherHost extends RPCHost {
334
  r.description = upstreamSearchResult.description;
335
 
336
  return r;
337
- }).catch((err)=> {
338
  this.logger.error(`Failed to format snapshot for ${urls[i].href}`, { err: marshalErrorLike(err) });
339
 
340
  return {
 
109
  throw new InsufficientBalanceError(`Account balance not enough to run this query, please recharge.`);
110
  }
111
 
112
+ const rateLimitPolicy = auth.getRateLimits(rpcReflect.name.toUpperCase()) || [
113
+ parseInt(user.metadata?.speed_level) >= 2 ?
114
+ RateLimitDesc.from({
115
+ occurrence: 200,
116
+ periodSeconds: 60
117
+ }) :
118
+ RateLimitDesc.from({
119
+ occurrence: 40,
120
+ periodSeconds: 60
121
+ })
122
+ ];
123
 
124
  const apiRoll = await this.rateLimitControl.simpleRPCUidBasedLimit(
125
  rpcReflect, uid, [rpcReflect.name.toUpperCase()],
 
341
  r.description = upstreamSearchResult.description;
342
 
343
  return r;
344
+ }).catch((err) => {
345
  this.logger.error(`Failed to format snapshot for ${urls[i].href}`, { err: marshalErrorLike(err) });
346
 
347
  return {
thinapps-shared CHANGED
@@ -1 +1 @@
1
- Subproject commit a26b633136a2651f01dcf02b47efc35b2401d807
 
1
+ Subproject commit fe71cc2433f60ada86622f1670a752da40806e4d