Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor(coderd/provisionerdserver): use quartz.Clock instead of TimeNowFn #15642

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

Merged
merged 3 commits into from
Nov 25, 2024

Conversation

DanielleMaywood
Copy link
Contributor

@DanielleMaywood DanielleMaywood commented Nov 25, 2024

Relates to #15082 (comment) (and #15594)

For testing the autostart change in the linked PR we need to have control over time in the provisionerdserver. Currently that is possible with a TimeNowFn but this wasn't hooked up to coderd. This PR replaces TimeNowFn in provisionerdserver with quartz.Clock as well as passes coderd's Clock to provisionerdserver.

@DanielleMaywood DanielleMaywood changed the title refactor(provisionerdserver): use quartz.Clock instead of TimeNowFn refactor(coderd/provisionerdserver): use quartz.Clock instead of TimeNowFn Nov 25, 2024
@DanielleMaywood DanielleMaywood marked this pull request as ready for review November 25, 2024 15:38
@DanielleMaywood DanielleMaywood marked this pull request as draft November 25, 2024 15:44
@DanielleMaywood DanielleMaywood marked this pull request as ready for review November 25, 2024 15:58
Comment on lines +237 to +238
func (s *server) timeNow(tags ...string) time.Time {
return dbtime.Time(s.Clock.Now(tags...))
Copy link
Member

Choose a reason for hiding this comment

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

nice 👍

Comment on lines +196 to +198
if options.Clock == nil {
options.Clock = quartz.NewReal()
}
Copy link
Member

Choose a reason for hiding this comment

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

👍 Even if api.Clock is nil for some reason this should keep us covered.

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

Hell yeah

@DanielleMaywood DanielleMaywood merged commit 0896f33 into main Nov 25, 2024
27 checks passed
@DanielleMaywood DanielleMaywood deleted the dm-provisionerdserver-quartz branch November 25, 2024 16:25
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.

3 participants