-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add rpc load blance call helper #2876
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
base: master
Are you sure you want to change the base?
Conversation
helpers/rpc.ts
Outdated
const GlobalEndpointsCooldown: { [key: string]: number } = {} | ||
|
||
async function sleep(time: number) { | ||
return new Promise((resolve) => setTimeout(resolve, time)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setTimeout uses millisecond format iirc, so need to either *1000 here or send in ms in calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
helpers/rpc.ts
Outdated
|
||
// anyway, sleep one second | ||
await sleep(1) | ||
} while(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I dont like the idea of infinitely looping till something works, sometimes the request is bad
helpers/rpc.ts
Outdated
|
||
if (httpResponse.status === 200) { | ||
return httpResponse.data | ||
} else if (httpResponse.status >= 400 && httpResponse.status < 500) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, what if the request is bad, like we are requesting for token details of non existent token? we are punishing the endpoint for a bad request. maybe instead of immediately cooling down a endpoint, we see if some other endpoint gives 200 result and then add cooldown to bad endpoint based on their response/error code?
Add a helper function help to balance and cache rpc calls