-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Expose cache ttl for es span writer index+service #2737
Conversation
Signed-off-by: Tyghe Vallard <vallardt@gmail.com> Signed-off-by: Tyghe Vallard <tyghe.vallard@target.com>
Codecov Report
@@ Coverage Diff @@
## master #2737 +/- ##
==========================================
+ Coverage 95.83% 95.84% +0.01%
==========================================
Files 217 217
Lines 9650 9656 +6
==========================================
+ Hits 9248 9255 +7
Misses 331 331
+ Partials 71 70 -1
Continue to review full report at Codecov.
|
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.
- please add test coverage
- how would someone use this functionality? it is not exposed via CLI flags
ServiceCacheDuration string | ||
IndexCacheDuration string |
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.
ServiceCacheDuration string | |
IndexCacheDuration string | |
ServiceCacheDuration time.Duration | |
IndexCacheDuration time.Duration |
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.
You cannot check if a time.Duration is set or not since it would be 0, but you can check if a string is empty which is why I went the path I did there.
Anybody directly using the writer in their own code can use it and if later somebody wants to plumb in the ability for a flag for the apps to be able to set these could do that in a separate PR
I'm not sure how to test this since everything is in a private property and I cannot check if they are set in a test
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.
What's wrong with 0? 0 is not a valid value for these parameters, so it works perfectly well as "unset" value.
Tests run in the private package namespace and can test those values.
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.
0 is a valid value and would indicate caching forever so you still would not be able to differentiate from cache forever and not being set. Unless you want to assume that nobody would ever want to cache forever(which could be a valid thing, but I would rather be able to know for sure)
I did figure out how to test and just pushed those
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.
0 is a valid value and would indicate caching forever
Technically, for the LRU cache that is used under the hood, the ttl=0 is a valid param. But in the context of the specific caching scenarios here (index and service names) I do not believe 0 is a valid value, because these caches grow over time. So we can use 0 as "undefined". If people want to cache "forever" they can still do it by providing a very long duration.
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.
Sounds good. I can make the change
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.
If you really want to support "undefined" then the other alternative is to use a pointer.
Signed-off-by: Tyghe Vallard <tyghe.vallard@target.com>
Signed-off-by: Tyghe Vallard <tyghe.vallard@target.com>
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.
Thanks!
Which problem is this PR solving?
Short description of the changes