Skip to content

Question: how to function-rate-limit in a module? #4

Description

@marcolino

Just a bit weird question:
I'm building a module ("network-request"), which places http requests.
I'd like to integrate "function-rate-limit" functionality in it, but I can't understand how to do it...
I did try:

exports.myRequestLimited = rateLimit(1, 3 * 1000, function(url, provider, error, success) {
  exports.myRequest(url, provider, error, success);
});

exports.myRequest = function(url, provider, error, success) {
  // my logic here...
});

Which works, but I don't like it, since, for example, I can't pass it the limits (1 request every 3 seconds, in this example...).

I'd prefer something like this:

exports.MyRequestLimited = function(url, provider, error, success) {
  return rateLimit(1, 3 * 1000, function(url, provider, error, success) {
    exports.myRequest(url, provider, error, success);
  });
});

But this doesn't work (it freezes...).
Any clues?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions