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

feat: Cache piercing for discovery and async-dns #32260

Conversation

johanandren
Copy link
Member

This makes it possible to programatically force re-resolution even if TTL is long, needed downstream in Akka gRPC for periodic refresh of nodes used for client side load balancing.

@@ -74,12 +74,18 @@ class SimpleDnsCache extends Dns with PeriodicCacheCleanup with NoSerializationV
}

@tailrec
private[io] final def put(key: (String, RequestType), records: Resolved, ttl: CachePolicy): Unit = {
private[akka] final def put(key: (String, RequestType), records: Resolved, ttl: CachePolicy): Unit = {
Copy link
Member Author

Choose a reason for hiding this comment

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

Opened up slightly to be able to write test in discovery

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

LGTM, after minor

@johanandren johanandren merged commit 38cd556 into akka:main Dec 18, 2023
5 checks passed
@johanandren johanandren deleted the wip-cache-piercing-for-discover-and-async-dns branch December 18, 2023 13:55
@johanandren johanandren added this to the 2.9.1 milestone Dec 18, 2023
@leviramsey
Copy link
Contributor

I'm wondering if an alternative approach of setting a maximum DNS TTL would be conceptually cleaner than exposing a drop operation on the cache through service discovery?

@johanandren
Copy link
Member Author

This is not intended as general purpose but a means for a specific downstream feature in Akka gRPC for discovering updated sets of services to load balance over. Forcing all cache to be dropped for that purpose seems wasteful and would also not be enough for that feature since we also need the drop to trigger a refreshed list to push into the gRPC client.

@johanandren
Copy link
Member Author

For the record, this is the Akka gRPC functionality PR: akka/akka-grpc#1886

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.

None yet

3 participants