{"id":19932757,"url":"https://github.com/mixmaxhq/node-distributed-throttle-function","last_synced_at":"2025-05-03T11:32:53.956Z","repository":{"id":49156318,"uuid":"56009518","full_name":"mixmaxhq/node-distributed-throttle-function","owner":"mixmaxhq","description":"Distributed throttle() function (like Underscore) that uses Redis","archived":false,"fork":false,"pushed_at":"2023-11-28T16:11:10.000Z","size":77,"stargazers_count":6,"open_issues_count":3,"forks_count":2,"subscribers_count":33,"default_branch":"master","last_synced_at":"2024-10-11T09:12:27.945Z","etag":null,"topics":["corgi-tag"],"latest_commit_sha":null,"homepage":"https://www.mixmax.com/careers","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mixmaxhq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-04-11T21:37:54.000Z","updated_at":"2024-05-30T22:57:17.000Z","dependencies_parsed_at":"2023-11-28T17:30:47.045Z","dependency_job_id":"8c4669fd-c7fa-49f7-91ee-ad34c7b7bd11","html_url":"https://github.com/mixmaxhq/node-distributed-throttle-function","commit_stats":{"total_commits":22,"total_committers":4,"mean_commits":5.5,"dds":0.5,"last_synced_commit":"5c932494246f403c91f14e4dfea874cc051f8bfa"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fnode-distributed-throttle-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fnode-distributed-throttle-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fnode-distributed-throttle-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixmaxhq%2Fnode-distributed-throttle-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mixmaxhq","download_url":"https://codeload.github.com/mixmaxhq/node-distributed-throttle-function/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224360219,"owners_count":17298319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["corgi-tag"],"created_at":"2024-11-12T23:11:27.855Z","updated_at":"2024-11-12T23:11:28.484Z","avatar_url":"https://github.com/mixmaxhq.png","language":"JavaScript","readme":"## Distributed Throttle\n\nThis module allows you to throttle the invocation of a function (just like [Underscore#throttle](http://underscorejs.org/#throttle)) across a distributed system. It is built on top of Redis. It will currently always call the function on the leading edge and the trailing edge, just like Underscore's default implementation.\n\n## Installing \n\n```bash\nnpm install node-distributed-throttle-function\n```\n\n## Using\n\n```js\nvar distributedThrottle = require('node-distributed-throttle-function');\nvar redis = require('redis');\n\nvar port = '6381';\nvar hostname = 'localhost';\nvar password = '';\n\nvar redisConnection = redis.createClient(port, hostname, {\n  auth_pass: password\n};\n\nvar throttle = distributedThrottle(redisConnection);\n\n// This function will be called immediately unless it has been called less than 10 seconds ago.\n// In that case, it will be called in 10 seconds—unless some _other_ call has happened in that interval.\nthrottle.call('my10secThrottledFunction', function(err) {\n  if (err) {\n    console.log('error!', err);\n    return;\n  }\n\n  console.log('This function will be called at most once (possibly zero times) within the next 10 seconds.');\n}, 10 * 1000 /* 10 sec */);\n\n// If you want to cancel any pending call such that the next invocation will fire immediately.\nthrottle.cancel('my10secThrottledFunction', function(err){\n  if (err) {\n    console.log('error!', err);\n  } \n});\n\n```\n\n## Bugs \u0026 TODOs\n\nSee \u003chttps://github.com/mixmaxhq/node-distributed-throttle-function/issues\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixmaxhq%2Fnode-distributed-throttle-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmixmaxhq%2Fnode-distributed-throttle-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixmaxhq%2Fnode-distributed-throttle-function/lists"}