Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Conversation

@jdecaron
Copy link
Contributor

@jdecaron jdecaron commented Mar 9, 2020

This is a simple fix, maximum of 10 requests per seconds = maximum of 600 requests per minutes. It does slow down a bit the report but it prevent a fatal error. It's possible to design a more sophisticated fix but it will be more complex with more states to manage. It would be more prone to bugs. I favor simplicity over maximum speed.

This is a simple fix, maximum of 10 requests per seconds = maximum of 600 requests per minutes. It does slow down a bit the report but it prevent a fatal error. It's possible to design a more sophisticated fix but it will be more complex with more states to manage. It would be more prone to bugs. I favor simplicity over maximum speed.
@adescoms
Copy link

adescoms commented Apr 7, 2020

Hi, this PR would help us to solve #82 and #73 because we're overrating the GitLab limit (10 requests per second), can I help in something to move it forward? @kriskbx @jdecaron

@cgdobre cgdobre self-assigned this Jun 3, 2020
Copy link
Collaborator

@cgdobre cgdobre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution. It will be a great improvement!

Comment on lines 5 to 7
const throttledQueue = require('throttled-queue');

const throttle = throttledQueue(10, 1000);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have a way to configure requests per second, as it is done now for parallel. Of course, this means also that:

  • the declaration of throttle needs to be moved inside the base object.

  • the new throttle parameter needs to be added in the configuration

Suggested change
const throttledQueue = require('throttled-queue');
const throttle = throttledQueue(10, 1000);
const throttledQueue = require('throttled-queue');
[...]
let throttle = throttledQueue(this._throttle, 1000);
[...]

Comment on lines 42 to 56
throttle(() => {
request.post(`${this.url}${path}`, {
json: true,
body: data,
insecure: this._insecure,
proxy: this._proxy,
resolveWithFullResponse: true,
headers: {
'PRIVATE-TOKEN': this.token
}
}).then(response => {
if (this.config.get('_createDump')) this.setDump(response, key);
resolve(response);
}).catch(e => reject(e));
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move throttle() on line up to minimize the diff

Suggested change
throttle(() => {
request.post(`${this.url}${path}`, {
json: true,
body: data,
insecure: this._insecure,
proxy: this._proxy,
resolveWithFullResponse: true,
headers: {
'PRIVATE-TOKEN': this.token
}
}).then(response => {
if (this.config.get('_createDump')) this.setDump(response, key);
resolve(response);
}).catch(e => reject(e));
})
return new Promise((resolve, reject) => throttle(() => {
request.post(`${this.url}${path}`, {
json: true,
body: data,
insecure: this._insecure,
proxy: this._proxy,
resolveWithFullResponse: true,
headers: {
'PRIVATE-TOKEN': this.token
}
}).then(response => {
if (this.config.get('_createDump')) this.setDump(response, key);
resolve(response);
}).catch(e => reject(e));
}));

Comment on lines 74 to 88
return new Promise((resolve, reject) => {
request(`${this.url}${path}`, {
json: true,
insecure: this._insecure,
proxy: this._proxy,
resolveWithFullResponse: true,
headers: {
'PRIVATE-TOKEN': this.token
}
}).then(response => {
if (this.config.get('_createDump')) this.setDump(response, key);
resolve(response);
}).catch(e => reject(e));
throttle(() => {
request(`${this.url}${path}`, {
json: true,
insecure: this._insecure,
proxy: this._proxy,
resolveWithFullResponse: true,
headers: {
'PRIVATE-TOKEN': this.token
}
}).then(response => {
if (this.config.get('_createDump')) this.setDump(response, key);
resolve(response);
}).catch(e => reject(e));
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same suggestion as above. Move throttle one line up and un-indent the request lines to minimize the diff.

@cgdobre
Copy link
Collaborator

cgdobre commented Jun 3, 2020

PS: also update and include the yarn.lock file because the CI job fails without it

@cgdobre
Copy link
Collaborator

cgdobre commented Jun 3, 2020

PS2: goes without saying, if you need any help with the changes, just ask.

- whitepace magic to minimize diff
- update yarn.lock file
@coveralls
Copy link

Coverage Status

Coverage remained the same at 65.979% when pulling e032d1c on jdecaron:fix-rate-limit into e059f1f on kriskbx:master.

@cgdobre cgdobre merged commit f377108 into kriskbx:master Jun 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report fails if the number of issues is too high Cannot process issues

5 participants