Liking cljdoc? Tell your friends :D

lb.dns

DNS-based backend resolution for dynamic environments.

Provides:

  • DNS hostname support for backend targets
  • Periodic re-resolution with configurable intervals
  • Multiple A record expansion to weighted targets
  • Graceful failure handling with last-known-good fallback

Usage: ;; In configuration :default-target {:host "backend.local" :port 8080 :dns-refresh-seconds 30}

;; Programmatic usage (dns/start!) (dns/register-target! "proxy-name" "hostname" config update-fn) (dns/get-status "proxy-name") (dns/stop!)

DNS-based backend resolution for dynamic environments.

Provides:
- DNS hostname support for backend targets
- Periodic re-resolution with configurable intervals
- Multiple A record expansion to weighted targets
- Graceful failure handling with last-known-good fallback

Usage:
  ;; In configuration
  :default-target {:host "backend.local" :port 8080 :dns-refresh-seconds 30}

  ;; Programmatic usage
  (dns/start!)
  (dns/register-target! "proxy-name" "hostname" config update-fn)
  (dns/get-status "proxy-name")
  (dns/stop!)
raw docstring

force-resolve!clj

(force-resolve! proxy-name hostname)

Force immediate DNS re-resolution for a hostname. Useful for testing or manual refresh after DNS changes.

Force immediate DNS re-resolution for a hostname.
Useful for testing or manual refresh after DNS changes.
sourceraw docstring

get-all-statusclj

(get-all-status)

Get DNS resolution status for all proxies.

Get DNS resolution status for all proxies.
sourceraw docstring

get-statusclj

(get-status proxy-name)

Get DNS resolution status for a proxy.

Returns map with: :proxy-name - Proxy name :targets - Map of hostname -> status including: :hostname, :port, :weight, :refresh-ms :last-ips, :last-resolved-at, :consecutive-failures

Get DNS resolution status for a proxy.

Returns map with:
  :proxy-name - Proxy name
  :targets - Map of hostname -> status including:
    :hostname, :port, :weight, :refresh-ms
    :last-ips, :last-resolved-at, :consecutive-failures
sourceraw docstring

register-target!clj

(register-target! proxy-name hostname config update-callback)

Register a DNS-backed target for periodic resolution.

Parameters: proxy-name - Name of the proxy this target belongs to hostname - DNS hostname to resolve config - Map with: :port - Target port (required) :weight - Weight for this target (default 100) :dns-refresh-seconds - Refresh interval (default 30) :health-check - Optional health check config update-callback - Function called with (hostname target-group) when IPs change

Returns true if registered successfully.

Throws exception if initial DNS resolution fails (startup failure).

Register a DNS-backed target for periodic resolution.

Parameters:
  proxy-name - Name of the proxy this target belongs to
  hostname - DNS hostname to resolve
  config - Map with:
    :port - Target port (required)
    :weight - Weight for this target (default 100)
    :dns-refresh-seconds - Refresh interval (default 30)
    :health-check - Optional health check config
  update-callback - Function called with (hostname target-group) when IPs change

Returns true if registered successfully.

Throws exception if initial DNS resolution fails (startup failure).
sourceraw docstring

resolve-all-ipsclj

(resolve-all-ips hostname)

Resolve a hostname and return vector of IP strings, or nil on failure.

Resolve a hostname and return vector of IP strings, or nil on failure.
sourceraw docstring

resolve-hostnameclj

(resolve-hostname hostname)

Resolve a hostname directly (bypass caching). Returns ResolveResult with :success?, :ips, :error-type, :message.

Resolve a hostname directly (bypass caching).
Returns ResolveResult with :success?, :ips, :error-type, :message.
sourceraw docstring

running?clj

(running?)

Check if the DNS resolution daemon is running.

Check if the DNS resolution daemon is running.
sourceraw docstring

start!clj

(start!)

Start the DNS resolution daemon. Called automatically during load balancer init.

Start the DNS resolution daemon.
Called automatically during load balancer init.
sourceraw docstring

stop!clj

(stop!)

Stop the DNS resolution daemon. Called automatically during load balancer shutdown.

Stop the DNS resolution daemon.
Called automatically during load balancer shutdown.
sourceraw docstring

subscribe!clj

(subscribe! callback)

Subscribe to DNS events.

Events have keys: :type - :dns-resolved or :dns-failed :proxy-name - Proxy name :hostname - Hostname that was resolved :timestamp - Event timestamp :data - Event-specific data

Returns unsubscribe function.

Subscribe to DNS events.

Events have keys:
  :type - :dns-resolved or :dns-failed
  :proxy-name - Proxy name
  :hostname - Hostname that was resolved
  :timestamp - Event timestamp
  :data - Event-specific data

Returns unsubscribe function.
sourceraw docstring

unregister-proxy!clj

(unregister-proxy! proxy-name)

Unregister all DNS targets for a proxy.

Unregister all DNS targets for a proxy.
sourceraw docstring

unregister-target!clj

(unregister-target! proxy-name hostname)

Unregister a DNS target and stop its refresh task.

Unregister a DNS target and stop its refresh task.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close