Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented minutely rate limit with pause #355

Closed
wants to merge 6 commits into from

Conversation

meijdenmedia
Copy link

@meijdenmedia meijdenmedia commented Mar 29, 2019

Fixing #255 for Laravel users.
Inspired by SoftTouch-bvba@60bd530

The package keeps track of the most recent refresh_token by saving it in the Laravel cache. This way you can spawn multiple processes at the same time without using an old refresh token. Before hitting the minute limit the script will pause if you allow it too (see readme).

Changed the README, updated minimum PHP version to 7.1 since all older versions are not supported anymore. For more info, see: https://www.php.net/supported-versions.php

Tomorrow I will deploy this package in our production environment.
Let's wait a couple of days before merging this.

@meijdenmedia
Copy link
Author

meijdenmedia commented Apr 24, 2019

Any thoughts on this one @stephangroen or @DannyvdSluijs ?
It is working for me in production.

@stephangroen
Copy link
Member

Thank you @meijdenmedia. I cannot merge this, because I don't like framework specific code in the library. It adds a lot of code for people that do not use Laravel.

I'm also not a fan of putting sleep in the library as a method of waiting on the rate limit. As you already commented, it literally stops code execution which you mostly do not want in production. In my opinion the library should enable the integrator to get the rate limits and act on that themselves. If you're using queues for example you might want to reschedule a job to a later time in stead of locking the queue on this job.

Also there is no need to up the PHP requirement to 7.1. Older versions might not be supported by PHP anymore, that doesn't mean those aren't used in production anymore. This changes breaks backward compatibility. I might bump to 7.x on a totally new version of this library so we can use alle the fancy new stuff in that new version :)

// todo: implement routes and migrations for authentication with Exact..
}

}
Copy link
Contributor

Choose a reason for hiding this comment

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

It misses EOF (end of file).

$this->acquireAccessToken();
}

}
Copy link
Contributor

Choose a reason for hiding this comment

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

It misses EOF (end of file).

{
if ($this->pauseForMinuteLimitEnabled()) {
if($this->minuteLimitExceeded()) {
sleep(60);
Copy link
Contributor

Choose a reason for hiding this comment

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

These conditions about coding style are very different.

I think this should be fixed and please check other codes in this PR.

I think other codes should have the same problem.

{
if ($this->pauseForMinuteLimitEnabled()) {
if($this->minuteLimitExceeded()) {
sleep(60);
Copy link
Contributor

Choose a reason for hiding this comment

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

I also think that using sleep function is not a good idea to do pause work.

I think we can present the message to tell developers need to pause request at this time.

},
"require-dev": {
"phpunit/phpunit": "~4.8.35"
},
"config": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we need to define the config block in composer.json?

I think it's up to developers to build their current development environment.

"php": ">=5.5.0",
"guzzlehttp/guzzle": "~6.0"
"ext-json": "*",
"php": ">=7.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this PR is plant to drop php-5.x and php-7.0 supports.

And just notice that we should drop these PHP versions in .travis.yml setting.

Copy link
Contributor

@peter279k peter279k left a comment

Choose a reason for hiding this comment

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

I think this PR has some issues should be concerned.

  • The Connection class has conflicts, and it should be fixed.
  • Some request changes I've written related comments on that line of code.
    Please consider them.

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

Successfully merging this pull request may close these issues.

None yet

3 participants