Liking cljdoc? Tell your friends :D

lb.circuit-breaker

Circuit breaker pattern for backend protection.

Prevents cascade failures by automatically stopping traffic to backends that are experiencing high error rates, allowing them time to recover.

State Machine:

  • CLOSED (normal): Traffic flows, errors are counted
  • OPEN (blocking): No traffic sent, waiting for timeout
  • HALF-OPEN (testing): Limited traffic to test recovery

Transitions:

  • CLOSED -> OPEN: When error rate exceeds threshold
  • OPEN -> HALF-OPEN: After open-duration-ms timeout
  • HALF-OPEN -> CLOSED: After N consecutive successes
  • HALF-OPEN -> OPEN: On any failure
Circuit breaker pattern for backend protection.

Prevents cascade failures by automatically stopping traffic to backends
that are experiencing high error rates, allowing them time to recover.

State Machine:
- CLOSED (normal): Traffic flows, errors are counted
- OPEN (blocking): No traffic sent, waiting for timeout
- HALF-OPEN (testing): Limited traffic to test recovery

Transitions:
- CLOSED -> OPEN: When error rate exceeds threshold
- OPEN -> HALF-OPEN: After open-duration-ms timeout
- HALF-OPEN -> CLOSED: After N consecutive successes
- HALF-OPEN -> OPEN: On any failure
raw docstring

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

lb.dns.manager

Background daemon for periodic DNS re-resolution.

Follows the same pattern as lb.health.manager:

  • ScheduledExecutorService for periodic tasks
  • Jitter to avoid thundering herd
  • Callbacks to update BPF maps on IP changes
  • Last-known-good fallback on failures
Background daemon for periodic DNS re-resolution.

Follows the same pattern as lb.health.manager:
- ScheduledExecutorService for periodic tasks
- Jitter to avoid thundering herd
- Callbacks to update BPF maps on IP changes
- Last-known-good fallback on failures
raw docstring

lb.dns.resolver

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
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
raw docstring

lb.drain

Connection draining for graceful backend removal. Allows backends to be drained by stopping new connections while allowing existing connections to complete.

Connection draining for graceful backend removal.
Allows backends to be drained by stopping new connections while
allowing existing connections to complete.
raw docstring

lb.health

Public API for health checking system. Provides a simple interface for managing health-aware load balancing.

Public API for health checking system.
Provides a simple interface for managing health-aware load balancing.
raw docstring

lb.health.checker

Health check implementations for TCP and HTTP protocols. Uses virtual threads for efficient concurrent checking.

Health check implementations for TCP and HTTP protocols.
Uses virtual threads for efficient concurrent checking.
raw docstring

lb.health.manager

Health check orchestration using virtual threads. Manages health state for all targets and triggers weight updates.

Health check orchestration using virtual threads.
Manages health state for all targets and triggers weight updates.
raw docstring

lb.health.weights

Weight redistribution logic for health-aware load balancing. Computes effective weights based on target health status.

Weight redistribution logic for health-aware load balancing.
Computes effective weights based on target health status.
raw docstring

lb.metrics

Prometheus metrics export for the load balancer.

Provides an HTTP endpoint for Prometheus scraping with metrics:

  • lb_connections_active - Current active connections
  • lb_bytes_total - Bytes transferred (forward/reverse)
  • lb_packets_total - Packets transferred
  • lb_backend_health - Backend health status (0/1)
  • lb_health_check_latency_seconds - Health check latency histogram
  • lb_dns_resolution_status - DNS resolution status

Usage: ;; In configuration :settings {:metrics {:enabled true :port 9090 :path "/metrics"}}

;; Programmatic usage (metrics/start! {:port 9090}) (metrics/register-data-sources! {...}) (metrics/stop!)

Prometheus metrics export for the load balancer.

Provides an HTTP endpoint for Prometheus scraping with metrics:
- lb_connections_active - Current active connections
- lb_bytes_total - Bytes transferred (forward/reverse)
- lb_packets_total - Packets transferred
- lb_backend_health - Backend health status (0/1)
- lb_health_check_latency_seconds - Health check latency histogram
- lb_dns_resolution_status - DNS resolution status

Usage:
  ;; In configuration
  :settings {:metrics {:enabled true :port 9090 :path "/metrics"}}

  ;; Programmatic usage
  (metrics/start! {:port 9090})
  (metrics/register-data-sources! {...})
  (metrics/stop!)
raw docstring

lb.metrics.collector

Collects and formats metrics in Prometheus text format.

Gathers data from various sources:

  • Connection tracking (active connections, bytes, packets)
  • Health checking (backend health status, latency)
  • DNS resolution (resolution status)
  • Stats aggregator (totals)
Collects and formats metrics in Prometheus text format.

Gathers data from various sources:
- Connection tracking (active connections, bytes, packets)
- Health checking (backend health status, latency)
- DNS resolution (resolution status)
- Stats aggregator (totals)
raw docstring

lb.metrics.histograms

Histogram implementation for Prometheus metrics.

Provides cumulative bucket histograms compatible with Prometheus format.

Histogram implementation for Prometheus metrics.

Provides cumulative bucket histograms compatible with Prometheus format.
raw docstring

lb.metrics.server

HTTP server for Prometheus metrics endpoint.

Provides a simple HTTP server using Java's built-in HttpServer that serves Prometheus-formatted metrics on a configurable endpoint.

HTTP server for Prometheus metrics endpoint.

Provides a simple HTTP server using Java's built-in HttpServer
that serves Prometheus-formatted metrics on a configurable endpoint.
raw docstring

lb.programs.common

Common eBPF program fragments and DSL utilities shared between XDP and TC programs.

Common eBPF program fragments and DSL utilities shared between XDP and TC programs.
raw docstring

lb.rate-limit

Rate limiting management for the load balancer.

Provides per-source IP and per-backend rate limiting using a token bucket algorithm. Rate limits are configured via BPF maps and enforced in the XDP program.

Token bucket parameters:

  • rate: tokens added per second (requests/sec)
  • burst: maximum tokens (handles traffic spikes)

Rate limiting is disabled by default (rate = 0).

Rate limiting management for the load balancer.

Provides per-source IP and per-backend rate limiting using a token bucket
algorithm. Rate limits are configured via BPF maps and enforced in the
XDP program.

Token bucket parameters:
- rate: tokens added per second (requests/sec)
- burst: maximum tokens (handles traffic spikes)

Rate limiting is disabled by default (rate = 0).
raw docstring

lb.reload

Configuration hot reload for the load balancer.

Provides:

  • File watching (inotify-based via Java NIO WatchService)
  • SIGHUP signal handling
  • Incremental configuration updates
  • Validation before apply with rollback on failure

Usage: ;; Enable hot reload for a config file (enable-hot-reload! "/etc/lb/config.edn")

;; Manual reload (reload-config!)

;; Disable hot reload (disable-hot-reload!)

Configuration hot reload for the load balancer.

Provides:
- File watching (inotify-based via Java NIO WatchService)
- SIGHUP signal handling
- Incremental configuration updates
- Validation before apply with rollback on failure

Usage:
  ;; Enable hot reload for a config file
  (enable-hot-reload! "/etc/lb/config.edn")

  ;; Manual reload
  (reload-config!)

  ;; Disable hot reload
  (disable-hot-reload!)
raw 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