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

Need to get the last sleepFor in the loop. #27

Closed

Conversation

QuantumEnergyE
Copy link

Need to get the last sleepFor in the loop, or slack will have no effect.

@CLAassistant
Copy link

CLAassistant commented Jul 28, 2020

CLA assistant check
All committers have signed the CLA.

@QuantumEnergyE
Copy link
Author

QuantumEnergyE commented Jul 29, 2020

TBR.
@mway @alxn @skywhat

@wanglongfei023
Copy link

cannot limit anymore as you code

rabbbit added a commit that referenced this pull request Oct 4, 2020
We currently have two different implementations. Currently:
- they're in the same package
- one of them is currently not tested
- one has a bug related to slack (see #27, #23)
- one has a broken constructor taking options affecting the other type

We plan to add at least 3 more implementations:
- one that addresses #22
- one that re-uses ratelimitfx atomic style
- one that compares us against x/time/rate

Even if we decide to eventually keep a single implementation,
they'll be there for a while. And I imagine it'll get noisy.

(A crazy idea would be to return different implementation based on
some user params. But that's totally TBD).

This diff tries to organize us a bit my moving the separate
implementations to separate packages.

Followups:
- will try to refactor the tests into a shared test package & re-use them.
  This way we can write tests once and make sure new implementations
  are working as expected.
- will try to make sure the implementations take equivalent
  configuration
- will have to modify the root ratelimit package to have stronger
  type guarantees, and not just aliasing methods - that would require
  a separate /types package though (I think).

Accidentally this diff is also changing signature of AfterFunc
in internal/clock package. This is so that it implements
it's own Clock interface. Looking at #3 though, I think
we can simply drop AfterFunc from the interface in followup diffs,
and re-use Clock from the root ratelimit package.
(We currently have two Clock interfaces defined, we can merge
them into a single one using a /types package trick) in a follow up.
rabbbit added a commit that referenced this pull request Dec 6, 2020
The ovarall goal is to be able to run the same tests on all possible
implementations so that we can verify they're working.

After #42 we can now configure limiters with the same options.

After this diff, the tests only pass in those options in to the testRunner.

A following diff will modify testRunner so that all tests are executed
on both atomic & mutex based limiters.

This in turn allows us to change the limiters in sync & unblocks
resolving #27 & #23 (they are about the same bug)

This diff also
- changes the test to run in the same package.
  This is just so that I can access `option` without making it public,
  which seems unnecessary.
- renames runner into testRunner since it appears the benchmarks
  already define a `runner`. We might be able to merge them
  together but that's for another diff.
rabbbit added a commit that referenced this pull request Dec 7, 2020
The ovarall goal is to be able to run the same tests on all possible
implementations so that we can verify they're working.

After #42 we can now configure limiters with the same options.

After this diff, the tests only pass in those options in to the testRunner.

A following diff will modify testRunner so that all tests are executed
on both atomic & mutex based limiters.

This in turn allows us to change the limiters in sync & unblocks
resolving #27 & #23 (they are about the same bug)

This diff also
- changes the test to run in the same package.
  This is just so that I can access `option` without making it public,
  which seems unnecessary.
- renames runner into testRunner since it appears the benchmarks
  already define a `runner`. We might be able to merge them
  together but that's for another diff.
rabbbit added a commit that referenced this pull request Dec 14, 2020
The ovarall goal is to be able to run the same tests on all possible
implementations so that we can verify they're working.

After #42 we can now configure limiters with the same options.

After this diff, the tests only pass in those options in to the testRunner.

A following diff will modify testRunner so that all tests are executed
on both atomic & mutex based limiters.

This in turn allows us to change the limiters in sync & unblocks
resolving #27 & #23 (they are about the same bug)

This diff also
- changes the test to run in the same package.
  This is just so that I can access `option` without making it public,
  which seems unnecessary.
- renames runner into testRunner since it appears the benchmarks
  already define a `runner`. We might be able to merge them
  together but that's for another diff.
rabbbit added a commit that referenced this pull request Jan 3, 2021
As reported in #23 and #27 slack is currently broken in the atomic
implementation.

Both #23 and #27 propose valid solutions, and I actually arrived
at #23 when trying to solve this independently, but I find #27
slightly more readable/understandable, so going with that.

Also, #23 seems to expose another bug in andres-erbsen/clock, with
sleeping with negative time, so we should probably consider switching
to benbjohnson/clock - maybe in a follow up.
@rabbbit rabbbit mentioned this pull request Jan 3, 2021
rabbbit added a commit that referenced this pull request Jan 19, 2021
As reported in #23 and #27 slack is currently broken in the atomic
implementation.

Both #23 and #27 propose valid solutions, and I actually arrived
at #23 when trying to solve this independently, but I find #27
slightly more readable/understandable, so going with that.

Also, #23 seems to expose another bug in andres-erbsen/clock, with
sleeping with negative time, so we should probably consider switching
to benbjohnson/clock - maybe in a follow up.
rabbbit added a commit that referenced this pull request Jan 25, 2021
* Fix not working slack.

As reported in #23 and #27 slack is currently broken in the atomic
implementation.

Both #23 and #27 propose valid solutions, and I actually arrived
at #23 when trying to solve this independently, but I find #27
slightly more readable/understandable, so going with that.

Also, #23 seems to expose another bug in andres-erbsen/clock, with
sleeping with negative time, so we should probably consider switching
to benbjohnson/clock - maybe in a follow up.
@rabbbit
Copy link
Contributor

rabbbit commented Jan 25, 2021

Solved in #60 - using your idea, but with tests/in a different file.

@rabbbit rabbbit closed this Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants