Guest User

Untitled

a guest
Jul 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. const {RateLimiter} = require('limiter');
  2.  
  3. async function main(rate, interval) {
  4. const rateLimiter = new RateLimiter(rate, interval);
  5.  
  6. for await (const iter of queryBatches('ExampleTable', {keyConditionExpressoin: {...}, expressionAttributeValues: {...}})) {
  7. const {ConsumedCapacity} = iter.metadata();
  8.  
  9. for (const value of iter) {
  10. // You can use functional-pipelines to reduce or transduce the iterator as needed
  11. console.log(value);
  12. }
  13.  
  14. // Throttling
  15. await rateLimiter.getTokens(ConsumedCapacity);
  16. }
  17. }
  18.  
  19. main(10, 'second')
  20. .then(result => console.log(result)
  21. .catch(error => console.error(error);
Add Comment
Please, Sign In to add comment