Expose provider record TTL as options#1237
Conversation
|
I am unsure if it is better to split this up into separate PRs, it was a bit hard making the changes as they are all related to each other. Let me know if it is better to keep things in smaller changes. |
guillaumemichel
left a comment
There was a problem hiding this comment.
Thanks @phillebaba, it looks good! Just 1 line to fix
Signed-off-by: Philip Laine <philip.laine@gmail.com>
|
@guillaumemichel addressed your issue and expanded some of the TTL test because I realized the cache invalidation wasn't actually being tested with the original test. I also exposed the provider manager options as a DHT option. Similar to how swarm options are exposed in the host. I hope that is an ok solution. |
9b40b64 to
1d7ff4e
Compare
|
Exposing the options is OK, thanks! @phillebaba there seems to be a race in the newly introduced test. Could you please take a look? |
|
I realize now what is going on. AddProvider is eventually consistent. I didn't think about the logic properly until now, which explains why my lazy time.Sleep solution works but causes a data race. The add only blocks until the channel is consumed not until the record has been added to the cache and store. Without doing some major re-work I cant really see an easy fix for this. I think we either remove that part of the test for now or do something about it. I question how worth the work is considering the plans to refactor provider manager in the future. |
|
Refactored Everything looks good now, merging. Thank you for the contribution @phillebaba! |
This change exposes address TTL and provide validity as options in the provider manager, making it possible to configure these settings per instance. It also fixes the provider record returned by the cache to filter expired records before returning. This ensures that expired records are not returned if garbage collection has not been run yet.
Fixes #1228