-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Concurrent DNS cache -- -- Concurrent DNS cache @package concurrent-dns-cache @version 0.1.3 -- | DNS cache to resolve domains concurrently. module Network.DNS.Cache -- | Configuration for DNS cache. data DNSCacheConf DNSCacheConf :: [ResolvConf] -> Int -> NominalDiffTime -> NominalDiffTime -> NominalDiffTime -> DNSCacheConf -- | A list of resolvers (cache DNS servers). A domain is resolved by the -- resolvers concurrently. The first reply is used regardless of -- success/failure at this moment [resolvConfs] :: DNSCacheConf -> [ResolvConf] -- | Capability of how many domains can be resolved concurrently [maxConcurrency] :: DNSCacheConf -> Int -- | The minimum bound of cache duration for success replies in seconds. [minTTL] :: DNSCacheConf -> NominalDiffTime -- | The maximum bound of cache duration for success replies in seconds. [maxTTL] :: DNSCacheConf -> NominalDiffTime -- | The cache duration for failure replies in seconds. [negativeTTL] :: DNSCacheConf -> NominalDiffTime -- | An abstract data for DNS cache. Cached domains are expired every 10 -- seconds according to their TTL. data DNSCache -- | A basic function to create DNS cache. Domains should be resolved in -- the function of the second argument. withDNSCache :: (MonadBaseControl IO m, MonadIO m) => DNSCacheConf -> (DNSCache -> m a) -> m a -- | Lookup Domain in the cache. If not exist, queries are sent to -- DNS servers and resolved IP addresses are cached. lookup :: DNSCache -> Domain -> IO (Maybe HostAddress) -- | Lookup Domain only in the cache. lookupCache :: DNSCache -> Domain -> IO (Maybe HostAddress) -- | Information of positive result. data Result -- | An address obtained from the cache. Hit :: HostAddress -> Result -- | An address resolved from cache DNS servers. Resolved :: HostAddress -> Result -- | Specified domain is IP address. So, it is converted into a numeric -- address. Numeric :: HostAddress -> Result -- | Lookup Domain in the cache. If not exist, queries are sent to -- DNS servers and resolved IP addresses are cached. resolve :: DNSCache -> Domain -> IO (Either DNSError Result) -- | Lookup Domain only in the cache. resolveCache :: DNSCache -> Domain -> IO (Maybe (Either DNSError Result)) -- | Wait until the predicate in the second argument is satisfied. The -- predicate are given the number of the current resolving domains. -- -- For instance, if you ensure that no resolvings are going on: -- --
-- wait cache (== 0) ---- -- If you want to ensure that capability of concurrent resolving is not -- full: -- --
-- wait cache (< maxCon) ---- -- where maxCon represents maxConcurrency in -- DNSCacheConf. wait :: DNSCache -> (Int -> Bool) -> IO ()