Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cut nav into half #3664

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading