Skip to content

Commit d317562

Browse files
Cut nav into half (#3664)
Co-authored-by: app-token-issuer-data-feeds[bot] <134377064+app-token-issuer-data-feeds[bot]@users.noreply.github.com>
1 parent f8e1b54 commit d317562

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

.changeset/nasty-owls-serve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@chainlink/nav-consulting-adapter': patch
3+
---
4+
5+
Reduce rate limiter

packages/sources/nav-consulting/src/config/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export const config = new AdapterConfig(
1212
description:
1313
'The amount of time the background execute should sleep before performing the next request',
1414
type: 'number',
15-
default: 10_000,
15+
default: 60_000, // one call per minute
1616
},
1717
},
1818
{
1919
envDefaultOverrides: {
20-
CACHE_MAX_AGE: 300_000, // Due to API limit of 2 request per minute
20+
CACHE_MAX_AGE: 600_000, // 10 minute cache
2121
},
2222
},
2323
)

packages/sources/nav-consulting/src/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ export const adapter = new Adapter({
88
name: 'NAV_CONSULTING',
99
config,
1010
endpoints: [reserve],
11-
rateLimiting: {
12-
tiers: {
13-
default: {
14-
rateLimit1m: 4,
15-
note: '60/min in total shared by 30 EA instance, each EA can do 2 per min per API. Each call hits 2 API',
16-
},
17-
},
18-
},
1911
})
2012

2113
export const server = (): Promise<ServerInstance | undefined> => expose(adapter)

packages/sources/nav-consulting/src/transport/reserve.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ export class NavConsultingTransport extends SubscriptionTransport<BaseEndpointTy
3434
}
3535
async backgroundHandler(context: EndpointContext<BaseEndpointTypes>, entries: RequestParams[]) {
3636
await Promise.all(entries.map(async (param) => this.handleRequest(param)))
37-
await sleep(context.adapterSettings.BACKGROUND_EXECUTE_MS)
37+
if (entries.length == 0) {
38+
await sleep(1_000)
39+
} else {
40+
await sleep(context.adapterSettings.BACKGROUND_EXECUTE_MS)
41+
}
3842
}
3943

4044
async handleRequest(param: RequestParams) {

0 commit comments

Comments
 (0)