All this is subject to change/work in progress
The Problem
The LookupClient class has many properties which define the behavior of that class, like number of retries for a query, timeouts, caching etc...
All properties can be set at any point in time because LookupClient is not immutable.
Also, LookupClient is not a cheap object and it is advisable to reuse it as much as possible.
The problem with this is, that the state of LookupClient can be altered by different parts of an application and can cause unpredictable behavior.
For example, 2 different threads run a query with LookupClient at the same time. One sets UseCaching to true and one to false, before running the query.
There is no way to ensure thread safety at this point for the UseCaching property to be set correctly.
Solution
I will remove all properties from the LookupClient itself and move them to a options class which can be used to initialize LookupClient.
previous version
var client = new LookupClient(NameServer.GooglePublicDns)
{
UseCache = true,
EnableAuditTrail = false,
Retries = 3,
Timeout = TimeSpan.FromSeconds(10),
ThrowDnsErrors = true
};
new version
var client = new LookupClient(
new LookupClientOptions(NameServer.GooglePublicDns)
{
UseCache = true,
EnableAuditTrail = false,
Retries = 3,
Timeout = TimeSpan.FromSeconds(10),
ThrowDnsErrors = true
});
LookupClientOptions can be changed as much as needed before it gets passed to the client's ctor (which also give a little bit more flexibility to consumers).
After the LookupClient gets initialized, the options are stored as read-only copy and cannot be changed anymore.
The settings can be accessed via client.Settings.
This is a Breaking Change
Yes, this will be a bigger breaking change, because all the properties on the class are getting removed and the way to configure LookupClient changes.
Instead of removing the existing functionality right away, I will mark everything obsolete which will be removed some versions later (probably in 2.0).
Additional changes:
The list of name servers was a collection of IPEndPoints. IPEndPoint itself is mutable though, so it would be possible to change e.g. the IP address of an endpoint.
That will be changed, too. Instead, the NameServer class becomes an immutable type and will be used across the board.
Custom Queries
In version 1.1.0, I added "by server" query overloads which allows to query a different endpoint than configured initially.
Those endpoints will be removed alltogether in the next version (yes its breaking but I hope that feature wasn't really used much yet).
Instead, there will be new Query... methods taking a subset of LookupClientOptions as an additional/optional parameter.
There will be new overloads to Query, QueryAsync and QueryReverse which take DnsQueryOptions, which is a subset of LookupClientOptions.
With that, one can fully configure individual queries while still using the same client instance.
This feature can be used to query a dedicated endpoint or just use a different configuration for a particular query.
Example A, disabling cache for one query.
client.Query("google.com", QueryType.A, queryOptions: new DnsQueryOptions(NameServer.GooglePublicDns)
{
UseCache = false
});
The query options will replace any settings previously configured on the client. There is no fallback to what was configured previously (including name servers)!, except for name servers.
In case the passed in query options do not provide one or more name servers, the query will try to use the name servers of the LookupClient instance.
If anyone did read all of this ;) and has comments/ideas, let me know; happy to get feedback on this.
All this is subject to change/work in progress
Replace "by server" queries with optionalDnsQueryOptionsThe Problem
The
LookupClientclass has many properties which define the behavior of that class, like number of retries for a query, timeouts, caching etc...All properties can be set at any point in time because
LookupClientis not immutable.Also,
LookupClientis not a cheap object and it is advisable to reuse it as much as possible.The problem with this is, that the state of
LookupClientcan be altered by different parts of an application and can cause unpredictable behavior.For example, 2 different threads run a query with LookupClient at the same time. One sets
UseCachingtotrueand one tofalse, before running the query.There is no way to ensure thread safety at this point for the
UseCachingproperty to be set correctly.Solution
I will remove all properties from the
LookupClientitself and move them to a options class which can be used to initializeLookupClient.previous version
new version
LookupClientOptionscan be changed as much as needed before it gets passed to the client's ctor (which also give a little bit more flexibility to consumers).After the
LookupClientgets initialized, the options are stored as read-only copy and cannot be changed anymore.The settings can be accessed via
client.Settings.This is a Breaking Change
Yes, this will be a bigger breaking change, because all the properties on the class are getting removed and the way to configure
LookupClientchanges.Instead of removing the existing functionality right away, I will mark everything obsolete which will be removed some versions later (probably in 2.0).
Additional changes:
The list of name servers was a collection of
IPEndPoints.IPEndPointitself is mutable though, so it would be possible to change e.g. the IP address of an endpoint.That will be changed, too. Instead, the
NameServerclass becomes an immutable type and will be used across the board.Custom Queries
In version 1.1.0, I added "by server" query overloads which allows to query a different endpoint than configured initially.Those endpoints will be removed alltogether in the next version (yes its breaking but I hope that feature wasn't really used much yet).
Instead, there will be new
Query...methods taking a subset ofLookupClientOptionsas an additional/optional parameter.There will be new overloads to
Query,QueryAsyncandQueryReversewhich takeDnsQueryOptions, which is a subset ofLookupClientOptions.With that, one can fully configure individual queries while still using the same client instance.
This feature can be used to query a dedicated endpoint or just use a different configuration for a particular query.
Example A, disabling cache for one query.
The query options will replace any settings previously configured on the client. There is no fallback to what was configured previously
(including name servers)!, except for name servers.In case the passed in query options do not provide one or more name servers, the query will try to use the name servers of the
LookupClientinstance.If anyone did read all of this ;) and has comments/ideas, let me know; happy to get feedback on this.