-
Notifications
You must be signed in to change notification settings - Fork 203
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
Implement AfterFunc for Clock, FakeClock and IntervalClock #221
Implement AfterFunc for Clock, FakeClock and IntervalClock #221
Conversation
/sig api-machinery |
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.
One comment
@@ -116,6 +117,25 @@ func (f *FakeClock) NewTimer(d time.Duration) clock.Timer { | |||
return timer | |||
} | |||
|
|||
// AfterFunc is the Fake version of time.AfterFunc(d, cb). |
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.
Add a unit test for AfterFunc:
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.
565ef49
to
21bec34
Compare
Actually - the API diff is a good question. I can see a motivation for not allowing extending interfaces. [all the rest of the code remains as is] /assign @dims |
/hold |
@MadhavJivrajani hi~ sorry to bother, i was working on the same thing because i didn't found related issue(forgot to check prs) in the first place. My implements is quit the same #223 as yours but the testFunc maybe more clear. do u mind to merge my commit in your pr if u accept the testFunc? thx. |
Something like that sounds like what I would expect. |
…ntation. - WithDelayedExecution extends the Clock interface so as to not break code that currently uses the Clock interface. - Implement AfterFunc for RealClock, FakeClock and IntervalClock and add unit tests for the same Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
21bec34
to
9f0974d
Compare
Hi @jonyhy96 - no issues. Thanks for creating the PR. Atleast imo the tests in this commit are more appropriate because firstly they align with the existing tests upstream, while the tests you've written look clearer - I'm not sure its complete because we need to check if trigger happens for the right intervals in order and not just based off a count ( |
/lgtm @dims - can you help with approving this? |
/hold cancel |
Will vendor in k/k after this is merged and migrate the last bit of code :) |
no change in API, has test cases. @MadhavJivrajani FTW! this looks good to me. /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dims, MadhavJivrajani, wojtek-t The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR implements the
AfterFunc
method for the clocks ink8s.io/utils/clock
. Having this implemented,k8s.io/utils/clock
should be able to be a functional replacement ofk8s.io/apimachinery/pkg/util/clock
and we'll be one step closer to solving the divergent clock packages issue kubernetes/kubernetes#94738.Which issue(s) this PR fixes:
Fixes kubernetes/kubernetes#105173
Special notes for your reviewer:
None
Release note: