Skip to content

Commit

Permalink
Cut nav into half (#3664)
Browse files Browse the repository at this point in the history
Co-authored-by: app-token-issuer-data-feeds[bot] <134377064+app-token-issuer-data-feeds[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and akuzni2 committed Feb 4, 2025
1 parent d966d13 commit af491a7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-owls-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/nav-consulting-adapter': patch
---

Reduce rate limiter
4 changes: 2 additions & 2 deletions packages/sources/nav-consulting/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export const config = new AdapterConfig(
description:
'The amount of time the background execute should sleep before performing the next request',
type: 'number',
default: 10_000,
default: 60_000, // one call per minute
},
},
{
envDefaultOverrides: {
CACHE_MAX_AGE: 300_000, // Due to API limit of 2 request per minute
CACHE_MAX_AGE: 600_000, // 10 minute cache
},
},
)
8 changes: 0 additions & 8 deletions packages/sources/nav-consulting/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ export const adapter = new Adapter({
name: 'NAV_CONSULTING',
config,
endpoints: [reserve],
rateLimiting: {
tiers: {
default: {
rateLimit1m: 4,
note: '60/min in total shared by 30 EA instance, each EA can do 2 per min per API. Each call hits 2 API',
},
},
},
})

export const server = (): Promise<ServerInstance | undefined> => expose(adapter)
6 changes: 5 additions & 1 deletion packages/sources/nav-consulting/src/transport/reserve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export class NavConsultingTransport extends SubscriptionTransport<BaseEndpointTy
}
async backgroundHandler(context: EndpointContext<BaseEndpointTypes>, entries: RequestParams[]) {
await Promise.all(entries.map(async (param) => this.handleRequest(param)))
await sleep(context.adapterSettings.BACKGROUND_EXECUTE_MS)
if (entries.length == 0) {
await sleep(1_000)
} else {
await sleep(context.adapterSettings.BACKGROUND_EXECUTE_MS)
}
}

async handleRequest(param: RequestParams) {
Expand Down

0 comments on commit af491a7

Please sign in to comment.