Core API for the eBPF load balancer. Provides high-level functions for initialization, configuration, and management.
Core API for the eBPF load balancer. Provides high-level functions for initialization, configuration, and management.
(add-proxy! proxy-config)Add a new proxy configuration at runtime. Now supports weighted load balancing with TargetGroup records.
Add a new proxy configuration at runtime. Now supports weighted load balancing with TargetGroup records.
(add-sni-route! proxy-name hostname target)Add an SNI route to a proxy for TLS hostname-based routing. hostname: TLS SNI hostname to match (e.g., "api.example.com") target can be:
Add an SNI route to a proxy for TLS hostname-based routing.
hostname: TLS SNI hostname to match (e.g., "api.example.com")
target can be:
- Single target: {:ip "10.0.0.1" :port 8443}
- Weighted targets: [{:ip "10.0.0.1" :port 8443 :weight 50}
{:ip "10.0.0.2" :port 8443 :weight 50}](add-source-route! proxy-name source target)Add a source route to a proxy. target can be:
Add a source route to a proxy.
target can be:
- Single target: {:ip "10.0.0.1" :port 8080}
- Weighted targets: [{:ip "10.0.0.1" :port 8080 :weight 50}
{:ip "10.0.0.2" :port 8080 :weight 50}](attach-interfaces! interfaces)Attach proxy programs to network interfaces.
Attach proxy programs to network interfaces.
(circuit-breaker-enabled?)Check if circuit breaker is enabled.
Check if circuit breaker is enabled.
(clear-connections!)Clear all tracked connections.
Clear all tracked connections.
(clear-rate-limits!)Disable all rate limiting.
Disable all rate limiting.
(detach-interfaces! interfaces)Detach proxy programs from network interfaces.
Detach proxy programs from network interfaces.
(disable-backend-rate-limit!)Disable per-backend rate limiting.
Disable per-backend rate limiting.
(disable-hot-reload!)Disable hot configuration reload.
Disable hot configuration reload.
(disable-source-rate-limit!)Disable per-source rate limiting.
Disable per-source rate limiting.
(disable-stats!)Disable statistics collection.
Disable statistics collection.
(drain-backend! proxy-name target & {:keys [timeout-ms on-complete]})Start draining a backend. Stops new connections while existing ones complete.
proxy-name: Name of the proxy (e.g., "web") target: Target specification - "ip:port" string or {:ip :port} map
Options: :timeout-ms - Drain timeout in ms (default from config or 30000) :on-complete - Callback fn called with status (:completed, :timeout, :cancelled)
Returns DrainState or throws if target not found/already draining.
Start draining a backend. Stops new connections while existing ones complete.
proxy-name: Name of the proxy (e.g., "web")
target: Target specification - "ip:port" string or {:ip :port} map
Options:
:timeout-ms - Drain timeout in ms (default from config or 30000)
:on-complete - Callback fn called with status (:completed, :timeout, :cancelled)
Returns DrainState or throws if target not found/already draining.(draining? target)Check if a target is currently draining.
Check if a target is currently draining.
(enable-hot-reload! config-path & opts)Enable hot configuration reload for the specified config file.
Options: :watch-file? - Enable file watching (default true) :sighup? - Enable SIGHUP handling (default true) :debounce-ms - File change debounce period (default 500ms)
Returns true if enabled successfully.
Enable hot configuration reload for the specified config file. Options: :watch-file? - Enable file watching (default true) :sighup? - Enable SIGHUP handling (default true) :debounce-ms - File change debounce period (default 500ms) Returns true if enabled successfully.
(enable-stats!)Enable statistics collection.
Enable statistics collection.
(force-circuit-close! target-id)Manually force a circuit to CLOSED state (resume traffic).
Manually force a circuit to CLOSED state (resume traffic).
(force-circuit-open! target-id)Manually force a circuit to OPEN state (stop all traffic).
Manually force a circuit to OPEN state (stop all traffic).
(force-dns-resolve! proxy-name hostname)Force immediate DNS re-resolution for a hostname.
Force immediate DNS re-resolution for a hostname.
(get-all-circuit-breaker-status)Get circuit breaker status for all targets.
Get circuit breaker status for all targets.
(get-all-dns-status)Get DNS resolution status for all proxies.
Get DNS resolution status for all proxies.
(get-all-draining)Get all currently draining backends.
Returns seq of drain status maps.
Get all currently draining backends. Returns seq of drain status maps.
(get-all-health-status)Get health status for all proxies.
Get health status for all proxies.
(get-circuit-breaker-status target-id)Get circuit breaker status for a specific target.
Get circuit breaker status for a specific target.
(get-connection-count)Get the number of active connections.
Get the number of active connections.
(get-connection-stats)Get aggregated connection statistics.
Get aggregated connection statistics.
(get-connections)Get all active connections.
Get all active connections.
(get-dns-status proxy-name)Get DNS resolution status for a specific proxy.
Get DNS resolution status for a specific proxy.
(get-drain-status target)Get drain status for a backend.
target: Target specification - "ip:port" string or {:ip :port} map
Returns map with :target-id :status :elapsed-ms :current-connections or nil if not draining.
Get drain status for a backend.
target: Target specification - "ip:port" string or {:ip :port} map
Returns map with :target-id :status :elapsed-ms :current-connections
or nil if not draining.(get-health-status proxy-name)Get health status for a specific proxy.
Get health status for a specific proxy.
(get-rate-limit-config)Get all rate limit configuration. Returns {:per-source {...} :per-backend {...}} or nils for disabled limits.
Get all rate limit configuration.
Returns {:per-source {...} :per-backend {...}} or nils for disabled limits.(get-reload-state)Get current reload state for debugging.
Get current reload state for debugging.
(get-state)Get the current proxy state.
Get the current proxy state.
(health-check-enabled?)Check if health checking is enabled.
Check if health checking is enabled.
(hot-reload-enabled?)Check if hot reload is currently enabled.
Check if hot reload is currently enabled.
(init! config
&
{:keys [max-routes max-connections ringbuf-size]
:or
{max-routes 10000 max-connections 100000 ringbuf-size (* 256 1024)}})Initialize the eBPF reverse proxy.
Parameters: config - Configuration object (from config/parse-config or config/load-config-file)
Options: :max-routes - Maximum number of source routes :max-connections - Maximum concurrent connections :ringbuf-size - Ring buffer size for stats
Returns the proxy state map.
Initialize the eBPF reverse proxy. Parameters: config - Configuration object (from config/parse-config or config/load-config-file) Options: :max-routes - Maximum number of source routes :max-connections - Maximum concurrent connections :ringbuf-size - Ring buffer size for stats Returns the proxy state map.
(list-all-sni-routes)List all SNI routes from BPF map. Note: Returns hostname hashes since original hostnames aren't stored in BPF.
List all SNI routes from BPF map. Note: Returns hostname hashes since original hostnames aren't stored in BPF.
(list-attached-interfaces)List currently attached interfaces.
List currently attached interfaces.
(list-sni-routes proxy-name)List all SNI routes for a proxy. Returns a sequence of {:hostname :target-group} maps.
List all SNI routes for a proxy.
Returns a sequence of {:hostname :target-group} maps.(print-circuit-breaker-status)Print circuit breaker status for all targets.
Print circuit breaker status for all targets.
(print-config)Print current configuration.
Print current configuration.
(print-connections)Print active connections.
Print active connections.
(print-drain-status)Print all draining backends.
Print all draining backends.
(print-health-status)Print health status for all proxies.
Print health status for all proxies.
(print-rate-limit-status)Print current rate limit status.
Print current rate limit status.
(print-status)Print current load balancer status.
Print current load balancer status.
(rate-limiting-enabled?)Check if any rate limiting is enabled.
Check if any rate limiting is enabled.
(reload-config!)(reload-config! config-path)Reload configuration from file or provided source.
Without arguments, reloads from the last known config path (if hot reload is enabled). With a path argument, loads and applies that configuration file.
Returns {:success? bool :changes {...} :error ...}
Reload configuration from file or provided source.
Without arguments, reloads from the last known config path (if hot reload is enabled).
With a path argument, loads and applies that configuration file.
Returns {:success? bool :changes {...} :error ...}(reload-config-from-map! config-map)Reload configuration from an in-memory config map. Useful for programmatic config changes.
Returns {:success? bool :changes {...} :error ...}
Reload configuration from an in-memory config map.
Useful for programmatic config changes.
Returns {:success? bool :changes {...} :error ...}(remove-proxy! proxy-name)Remove a proxy configuration at runtime.
Remove a proxy configuration at runtime.
(remove-sni-route! proxy-name hostname)Remove an SNI route from a proxy.
Remove an SNI route from a proxy.
(remove-source-route! proxy-name source)Remove a source route from a proxy.
Remove a source route from a proxy.
(reset-circuit! target-id)Reset a circuit to initial CLOSED state with zero counts.
Reset a circuit to initial CLOSED state with zero counts.
(running?)Check if the proxy is currently running.
Check if the proxy is currently running.
(set-backend-rate-limit! rate & {:keys [burst]})Set per-backend rate limit.
rate: requests per second allowed to each backend burst: maximum burst size (defaults to 2x rate)
Returns true if successful.
Set per-backend rate limit. rate: requests per second allowed to each backend burst: maximum burst size (defaults to 2x rate) Returns true if successful.
(set-source-rate-limit! rate & {:keys [burst]})Set per-source IP rate limit.
rate: requests per second allowed from each source IP burst: maximum burst size (defaults to 2x rate)
Returns true if successful.
Set per-source IP rate limit. rate: requests per second allowed from each source IP burst: maximum burst size (defaults to 2x rate) Returns true if successful.
(shutdown!)Shutdown the reverse proxy and release all resources.
Shutdown the reverse proxy and release all resources.
(start-stats-stream!)Start streaming statistics events.
Start streaming statistics events.
(stats-enabled?)Check if statistics collection is enabled.
Check if statistics collection is enabled.
(stop-stats-stream!)Stop streaming statistics events.
Stop streaming statistics events.
(subscribe-to-stats)Subscribe to the stats stream. Returns a channel.
Subscribe to the stats stream. Returns a channel.
(undrain-backend! proxy-name target)Cancel draining and restore traffic to a backend.
proxy-name: Name of the proxy target: Target specification - "ip:port" string or {:ip :port} map
Returns true if undrain succeeded, false if target wasn't draining.
Cancel draining and restore traffic to a backend.
proxy-name: Name of the proxy
target: Target specification - "ip:port" string or {:ip :port} map
Returns true if undrain succeeded, false if target wasn't draining.(wait-for-drain! target)Block until drain completes or times out.
target: Target specification - "ip:port" string or {:ip :port} map
Returns :completed, :timeout, or :cancelled.
Block until drain completes or times out.
target: Target specification - "ip:port" string or {:ip :port} map
Returns :completed, :timeout, or :cancelled.(with-lb-state [binding] & body)Execute body with load balancer state bound to the specified binding. Returns nil if the load balancer is not running.
Example: (with-lb-state [state] (let [{:keys [maps config]} state] ;; work with state ))
Execute body with load balancer state bound to the specified binding.
Returns nil if the load balancer is not running.
Example:
(with-lb-state [state]
(let [{:keys [maps config]} state]
;; work with state
))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 |