-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat(library): add Duration() function to resources #222
Conversation
Codecov Report
@@ Coverage Diff @@
## master #222 +/- ##
==========================================
+ Coverage 96.74% 97.01% +0.27%
==========================================
Files 53 53
Lines 5645 5690 +45
==========================================
+ Hits 5461 5520 +59
+ Misses 137 125 -12
+ Partials 47 45 -2
|
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.
Looks good 👍 , one small typo that I spotted.
I think this is a lot cleaner than how it was previously set up with the duration helper functions. Thanks!
an afterthought, should a build in progress (ie. |
@wass3r initially, I thought the same thing and actually had written code to accomplish that 👍 However, when I started writing tests, I stumbled upon a reason why it may not be great for that to be the case 😅 The Line 810 in a10f36c
Line 356 in a10f36c
Line 449 in a10f36c
That UNIX timestamp actually refers to a time on After removing the In most scenarios, the functionality you described for durations would work 😃 The typical case for a resource to have a However, it's possible for a resource to get stuck/hung meaning it never gets a I decided to use |
Isn't it still misleading though? A running build (not hung) will show its duration as 0s if the callee is to use the returned value as is. I agree that hung builds are more of an outlier than running builds, so I think it's ok if the duration says something abnormally large. |
Yes, it is misleading either way 🤷 Would you rather have these functions return
Agreed 👍
Unfortunately, I don't agree 😞 |
I guess we disagree. I find it much more bothersome for a healthy running build to say it's been running for 0s (when it hasn't) than a rare hung build to tell me it has been running for 6 months. If used in the CLI (for example), I would not use the value as is. I think folks would prefer either the current running time, or something indeterminate like |
Would you like me to open up a PR that changes the behavior to The only downside I see to that is If someone were to use the https://go.dev/play/p/_sIxzHTyc9n On a positive note, the user would still get |
Currently, we have logic to calculate the duration (amount of time a resource was running) for various resources.
The following resources have this functionality:
This change introduces a
Duration()
method on each of these resources that will replace the above linked functions:types/library/build.go
Lines 51 to 70 in 16db0db
types/library/service.go
Lines 36 to 55 in 16db0db
types/library/step.go
Lines 38 to 57 in 16db0db