-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Fix #44: Use PSR-20 ClockInterface instead of TimerInterface #47
Conversation
samdark
commented
Jul 25, 2023
Q | A |
---|---|
Is bugfix? | ❌ |
New feature? | ❌ |
Breaks BC? | ✔️ |
Fixed issues | #44 |
PR Summary:
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #47 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 51 51
===========================================
Files 9 9
Lines 135 135
===========================================
Hits 135 135
☔ View full report in Codecov by Sentry. |
@@ -75,7 +75,7 @@ public function hit(string $id): CounterState | |||
do { | |||
// Last increment time. | |||
// In GCRA it's known as arrival time. | |||
$lastIncrementTimeInMilliseconds = $this->timer->nowInMilliseconds(); | |||
$lastIncrementTimeInMilliseconds = round((float)$this->timer->now()->format('U.u') * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$lastIncrementTimeInMilliseconds = round((float)$this->timer->now()->format('U.u') * 1000); | |
$lastIncrementTimeInMilliseconds = round($this->timer->now()->format('U.u') * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would make static analysis complain.
@@ -227,7 +227,7 @@ public function testWithLimitingFunction(): void | |||
*/ | |||
public function testWithExceedingMaxAttempts(): void | |||
{ | |||
$timer = new FrozenTimeTimer(); | |||
$timer = new FrozenClock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we can don't use specific timer and replace it to null
.
@@ -259,7 +259,7 @@ public function testWithExceedingMaxAttempts(): void | |||
|
|||
public function testFailStoreUpdatedDataMiddleware(): void | |||
{ | |||
$timer = new FrozenTimeTimer(); | |||
$timer = new FrozenClock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we can don't use specific timer and replace it to null
.
@@ -34,20 +34,20 @@ public function testGetKeyWithExistsKey(): void | |||
{ | |||
$storage = $this->getStorage(); | |||
|
|||
$want = (new FrozenTimeTimer())->nowInMilliseconds(); | |||
$want = round((float)(new DateTimeImmutable())->format('U.u') * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$want = round((float)(new DateTimeImmutable())->format('U.u') * 1000); | |
$want = round((new DateTimeImmutable())->format('U.u') * 1000); |
} | ||
|
||
public function testSaveIfNotExistsWithNewKey(): void | ||
{ | ||
$storage = $this->getStorage(); | ||
|
||
$value = (new FrozenTimeTimer())->nowInMilliseconds(); | ||
$value = round((float)(new DateTimeImmutable())->format('U.u') * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$value = round((float)(new DateTimeImmutable())->format('U.u') * 1000); | |
$value = round((new DateTimeImmutable())->format('U.u') * 1000); |
@@ -58,7 +58,7 @@ public function testSaveCompareAndSwapWithExistsKeyAndOldValueSame(): void | |||
{ | |||
$storage = $this->getStorage(); | |||
|
|||
$oldValue = (new FrozenTimeTimer())->nowInMilliseconds(); | |||
$oldValue = round((float)(new DateTimeImmutable())->format('U.u') * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$oldValue = round((float)(new DateTimeImmutable())->format('U.u') * 1000); | |
$oldValue = round((new DateTimeImmutable())->format('U.u') * 1000); |
{ | ||
$storage = $this->getStorage(); | ||
|
||
$oldValue = (new FrozenTimeTimer())->nowInMilliseconds(); | ||
$oldValue = round((float)(new DateTimeImmutable())->format('U.u') * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$oldValue = round((float)(new DateTimeImmutable())->format('U.u') * 1000); | |
$oldValue = round((new DateTimeImmutable())->format('U.u') * 1000); |
@@ -47,7 +47,7 @@ public function testSaveCompareAndSwapWithNewKey(): void | |||
{ | |||
$storage = $this->getStorage(); | |||
|
|||
$newValue = (new FrozenTimeTimer())->nowInMilliseconds(); | |||
$newValue = round((float)(new DateTimeImmutable())->format('U.u') * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$newValue = round((float)(new DateTimeImmutable())->format('U.u') * 1000); | |
$newValue = round((new DateTimeImmutable())->format('U.u') * 1000); |
@@ -35,7 +35,7 @@ public function testSaveIfNotExistsWithExistsKey(): void | |||
{ | |||
$storage = $this->getStorage(); | |||
|
|||
$value = (new FrozenTimeTimer())->nowInMilliseconds(); | |||
$value = round((float)(new DateTimeImmutable())->format('U.u') * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$value = round((float)(new DateTimeImmutable())->format('U.u') * 1000); | |
$value = round((new DateTimeImmutable())->format('U.u') * 1000); |
*/ | ||
public function testConcurrentHitsWithDirtyReading(): void | ||
{ | ||
$timer = new FrozenTimeTimer(); | ||
$timer = new FrozenClock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we can don't use specific timer and replace it to null
.