Safe Haskell | None |
---|---|
Language | Haskell2010 |
DNS cache to resolve domains concurrently.
Synopsis
- data DNSCacheConf = DNSCacheConf {}
- data DNSCache
- withDNSCache :: (MonadBaseControl IO m, MonadIO m) => DNSCacheConf -> (DNSCache -> m a) -> m a
- lookup :: DNSCache -> Domain -> IO (Maybe HostAddress)
- lookupCache :: DNSCache -> Domain -> IO (Maybe HostAddress)
- data Result
- resolve :: DNSCache -> Domain -> IO (Either DNSError Result)
- resolveCache :: DNSCache -> Domain -> IO (Maybe (Either DNSError Result))
- wait :: DNSCache -> (Int -> Bool) -> IO ()
Documentation
data DNSCacheConf Source #
Configuration for DNS cache.
DNSCacheConf | |
|
An abstract data for DNS cache. Cached domains are expired every 10 seconds according to their TTL.
withDNSCache :: (MonadBaseControl IO m, MonadIO m) => DNSCacheConf -> (DNSCache -> m a) -> m a Source #
A basic function to create DNS cache. Domains should be resolved in the function of the second argument.
Looking up
lookup :: DNSCache -> Domain -> IO (Maybe HostAddress) Source #
Lookup Domain
in the cache.
If not exist, queries are sent to DNS servers and
resolved IP addresses are cached.
lookupCache :: DNSCache -> Domain -> IO (Maybe HostAddress) Source #
Lookup Domain
only in the cache.
Resolving
Information of positive result.
Hit HostAddress | An address obtained from the cache. |
Resolved HostAddress | An address resolved from cache DNS servers. |
Numeric HostAddress | Specified domain is IP address. So, it is converted into a numeric address. |
resolve :: DNSCache -> Domain -> IO (Either DNSError Result) Source #
Lookup Domain
in the cache.
If not exist, queries are sent to DNS servers and
resolved IP addresses are cached.
resolveCache :: DNSCache -> Domain -> IO (Maybe (Either DNSError Result)) Source #
Lookup Domain
only in the cache.
Waiting
wait :: DNSCache -> (Int -> Bool) -> IO () Source #
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
.