DNS resolution logic with multiple A record support.
Provides:
DNS resolution logic with multiple A record support. Provides: - Resolution of hostnames to all A records - Conversion of resolved IPs to weighted targets - Result types for success/failure handling
(distribute-weight total-weight n)Distribute a total weight among n targets. Returns a vector of weights that sum to the original weight.
Uses floor division with remainder distributed to first targets. Example: (distribute-weight 100 3) => [34 33 33]
Distribute a total weight among n targets. Returns a vector of weights that sum to the original weight. Uses floor division with remainder distributed to first targets. Example: (distribute-weight 100 3) => [34 33 33]
(expand-to-weighted-targets resolved-ips port total-weight health-check)Expand resolved IPs to weighted targets with distributed weights.
Parameters: resolved-ips - vector of u32 IPs from DNS resolution port - target port number total-weight - total weight to distribute (1-100) health-check - optional health check config
Returns vector of maps suitable for creating WeightedTargets: [{:ip <u32> :port <int> :weight <int> :health-check <config>} ...]
Expand resolved IPs to weighted targets with distributed weights.
Parameters:
resolved-ips - vector of u32 IPs from DNS resolution
port - target port number
total-weight - total weight to distribute (1-100)
health-check - optional health check config
Returns vector of maps suitable for creating WeightedTargets:
[{:ip <u32> :port <int> :weight <int> :health-check <config>} ...](failure-result error-type message)Create a failed resolution result.
Create a failed resolution result.
(format-ips ips)Format vector of u32 IPs as readable string.
Format vector of u32 IPs as readable string.
(ips-changed? old-ips new-ips)Check if resolved IPs have changed. Order-independent comparison.
Check if resolved IPs have changed. Order-independent comparison.
(resolve-hostname-all hostname timeout-ms)Resolve hostname to all A records.
Parameters: hostname - DNS hostname to resolve timeout-ms - Resolution timeout in milliseconds (not directly supported by Java InetAddress, but sets a reasonable expectation)
Returns ResolveResult with either:
Resolve hostname to all A records.
Parameters:
hostname - DNS hostname to resolve
timeout-ms - Resolution timeout in milliseconds (not directly supported
by Java InetAddress, but sets a reasonable expectation)
Returns ResolveResult with either:
- success? true, ips as vector of u32
- success? false, error-type and message(resolve-hostname-single hostname timeout-ms)Resolve hostname to first A record only. Simpler wrapper when only one IP is needed.
Returns ResolveResult.
Resolve hostname to first A record only. Simpler wrapper when only one IP is needed. Returns ResolveResult.
(success-result ips)(success-result ips ttl)Create a successful resolution result.
Create a successful resolution result.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |