starknet.js icon indicating copy to clipboard operation
starknet.js copied to clipboard

feat: rpc batch requests

Open ugur-eren opened this issue 1 year ago • 2 comments

Motivation and Resolution

The BatchClient class allows requests to be batched together, either by the interval amount, or at the end of the callback queue if set to 0. By batching requests, we can reduce the overhead associated with handling individual requests, optimize resource utilization and improve overall performance.

Request: Screenshot 2024-05-13 184213

Response: Screenshot 2024-05-13 184236

closes #758

Usage related changes

  • batch option added to RpcProvider options.

Development related changes

  • BatchClient class created to manage batching of requests.

Checklist:

  • [x] Performed a self-review of the code
  • [x] Rebased to the last commit of the target branch (or merged it into my branch)
  • [x] Linked the issues which this PR resolves
  • [ ] Documented the changes in code (API docs will be generated automatically)
  • [ ] Updated the tests
  • [x] All tests are passing

ugur-eren avatar May 13 '24 16:05 ugur-eren

I haven't gone into details yet, on first look, it seems good, but we need tests. Can you please add tests for new Classes and Batch requests, we must have tests for it before merging. Can you add a section to www/ documentation about usage? (optional - this can be done in separate PR)

tabaktoni avatar Jun 13 '24 09:06 tabaktoni

Hi @tabaktoni sorry for late reply, I didn't see the notification. I will add the tests ASAP. There is only a single function to test, won't take long. But about documentation, the new Batch class is only used in the RpcChannel class, it's not used externally and is not exported. If it's not preferred to have a class for this, we can also convert it to a function. But I thought a class would be easier and cleaner. Only usage change is a new batch option. I will add this option to the documentation.

ugur-eren avatar Jun 25 '24 07:06 ugur-eren

Hi @tabaktoni sorry for late reply. I've added tests and also moved the BatchClient class to utils, instead of the src. It is ready to review.

ugur-eren avatar Jul 06 '24 10:07 ugur-eren

:tada: This issue has been resolved in version 6.12.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Jul 26 '24 11:07 github-actions[bot]