Comments (7)
Nice initiative! Folsom uses dns-data in this way, see example here: https://github.com/spotify/folsom/blob/master/src/main/java/com/spotify/folsom/ketama/SrvKetamaClient.java
Should this new API perhaps also take a ScheduledExecutorService as input?
The API probably also needs a way to stop listening/polling for updates. I guess that would go into the PollingDnsSrvResolver object.
from dns-java.
@spkrka good points.
Providing a ScheduledExecutorService
when creating the poller makes sense, will add that.
I think having a way to cancel individual lookups would be useful too. Actually the EndpointProvider
interface has a close()
method that somehow got lost in the description. And a close method on PollingDnsSrvResolver
would then cancel all EndpointProvider
s created from that resolver.
On a side note; I'm not sure if I like the EndpointProvider
name. Can you think of something more descriptive?
from dns-java.
I guess I'd like the API to look something like this:
public class PeriodicDnsSrvUpdater {
public PeriodicDnsSrvUpdater(String fqdn, long period, TimeUnit unit, DnsSrvResolver resolver, ScheduledExecutorService service);
// stop polling for updates
public void close();
public void addListener(DnsSrvUpdateCallback callback);
public void removeListener(DnsSrvUpdateCallback callback);
}
public interface DnsSrvUpdateCallback {
void endpointsChanged(Set<HostAndPort> newEndpoints, Set<HostAndPort> oldEndpoints);
}
from dns-java.
Like the discussion so far, a couple of points:
- I think
HostAndPort
is too restrictive, given that you might want to include priority and weight in there as well. - I sort of think that doing conversion (and hence making the 'listener' take a type parameter) is potentially something best left outside this project. It wouldn't be hard or very noisy to write client code that simply applies a transform to the two Sets the listener receives, and I like the 'if in doubt, leave it out' approach.
Some thoughts about names:
- I think PeriodicDnsSrvUpdater and DnsSrvUpdateCallback are pretty descriptive, but also quite long.
- Another option could maybe be to take inspiration from Guava
CacheBuilder
, maybe something like:DnsSrvChangeNotifier
('Periodic' is perhaps redundant/too specific in the interface)ChangeListener
(since this is nested in the DnsSrvChangeNotifier, we might not need 'DnsSrv')onChange(ChangeNotification)
, where the ChangeNotification includes the two sets, and possibly some other information if we decide that is useful.
We could possibly drop 'Change' as well from the names.
We should probably write some client code for some of our use cases to see what it looks like.
from dns-java.
Re the type parameter, I just noticed that @rouzwawi was pointing out that including transformation in the API leads to more accurate notifications, since a change in a LookupResult might not be a change after the transformation. For instance, if somebody doesn't care about weight and priority and transforms to HostAndPort, then a change in weight for one of the results wouldn't lead to a notification. That I think motivates including transformation in the API.
from dns-java.
Updated API based on this thread and started implementation in #9
from dns-java.
Fixed by #9
from dns-java.
Related Issues (17)
- LookupResult should contain properly named getters HOT 2
- Question: Support of the Additional Section in the answer HOT 7
- Race condition when registering a listener with a watcher. HOT 1
- Provide a way to turn off response caching HOT 2
- package com.spotify.dns.statistics does not exist HOT 1
- feature-request: async lookup support HOT 1
- Depending on jsr305 is breaking java modules HOT 1
- QUESTION: Method to return a Random node.
- Not working when used in Tomcat Servlet HOT 2
- spring-boot metrics HOT 9
- `SERVFAIL` when trying to resolve a service address HOT 1
- new release timeline HOT 2
- Published jar's pom.xml lists outdated dnsjava dependency HOT 1
- Remove cachingLookups while initialising DnsSrvResolvers in BasicUsage class
- Local variable is shadowing class field
- consul integration review request HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dns-java.