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

Add WithDeadlineTimer interface to clock #312

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Jun 20, 2024

  1. Add WithDeadlineTimer interface to clock

    WithDeadlineTimer interface extends Clock to add NewDeadlineTimer.
    NewDeadlineTimer is similar to NewTimer, but it returns a timer which
    fires at the given timestamp.  It makes unit testing easier with
    FakeClock.Step when a test subject is making a timer inside goroutine
    (e.g., workqueue.NewDelayingQueue).  With NewTimer, in some race
    conditions, a timer never fire if FakeClock.Step is called after
    getting the base time Now() and calling NewTimer().  This is because
    the duration passed to timer is calculated against the old timestamp,
    but inside FakeClock.NewTimer, the targetTime is calculated against
    the time adjusted by Step.  With NewDeadlineTimer, targetTime is not
    adjusted, which works around this issue.
    tatsuhiro-t committed Jun 20, 2024
    Configuration menu
    Copy the full SHA
    c981c5a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5064795 View commit details
    Browse the repository at this point in the history