Config

Struct Config 

Source
pub struct Config {
Show 53 fields pub target_host: String, pub target_port: u16, pub upstream_command: Option<String>, pub upstream_args: Vec<String>, pub cache_size_bytes: usize, pub max_cache_item_size_bytes: usize, pub x_sendfile_enabled: bool, pub gzip_compression_enabled: bool, pub max_request_body: usize, pub tls_domains: Vec<String>, pub tls_cert_path: Option<String>, pub tls_key_path: Option<String>, pub acme_directory_url: String, pub eab_kid: Option<String>, pub eab_hmac_key: Option<String>, pub storage_path: String, pub bad_gateway_page: String, pub http_port: u16, pub https_port: u16, pub http_idle_timeout: Duration, pub http_read_timeout: Duration, pub http_write_timeout: Duration, pub h2c_enabled: bool, pub forward_headers: bool, pub log_requests: bool, pub log_level: LogLevel, pub shutdown_timeout_secs: u64, pub database_url: Option<String>, pub pg_channel_cache_invalidation: String, pub pg_channel_config_update: String, pub pg_channel_health: String, pub redis_url: Option<String>, pub toml_config: Option<TomlConfig>, pub rate_limit_enabled: bool, pub rate_limit_requests_per_sec: u32, pub rate_limit_burst_size: u32, pub upstream_timeout: Duration, pub circuit_breaker_enabled: bool, pub circuit_breaker_failure_threshold: u32, pub circuit_breaker_timeout_secs: u64, pub max_concurrent_requests: usize, pub metrics_enabled: bool, pub metrics_port: u16, pub static_enabled: bool, pub static_root: PathBuf, pub static_paths: Vec<String>, pub static_cache_control: String, pub static_gzip_enabled: bool, pub static_index_files: Vec<String>, pub static_fallthrough: bool, pub static_inline_size_limit: u64, pub client_ip_header: Option<String>, pub trusted_ranges_file: Option<PathBuf>,
}
Expand description

WarpDrive configuration

This struct contains all configuration options for WarpDrive, including proxy settings, caching, TLS/ACME, and PostgreSQL/Redis coordination features.

Fields§

§target_host: String

Hostname or IP of the upstream server to proxy to

§target_port: u16

Port of the upstream server to proxy to

§upstream_command: Option<String>

Command to spawn upstream process (for supervision)

§upstream_args: Vec<String>

Arguments for upstream command

§cache_size_bytes: usize

Total cache size in bytes

§max_cache_item_size_bytes: usize

Maximum size for a single cached item in bytes

§x_sendfile_enabled: bool

Enable X-Sendfile header support

§gzip_compression_enabled: bool

Enable gzip compression

§max_request_body: usize

Maximum request body size in bytes (0 = unlimited)

§tls_domains: Vec<String>

List of domains for TLS certificates

§tls_cert_path: Option<String>

Path to TLS certificate file (PEM format) - for self-signed or manual certs

§tls_key_path: Option<String>

Path to TLS private key file (PEM format) - for self-signed or manual certs

§acme_directory_url: String

ACME directory URL for certificate provisioning

§eab_kid: Option<String>

External Account Binding (EAB) key ID

§eab_hmac_key: Option<String>

External Account Binding (EAB) HMAC key

§storage_path: String

Storage path for TLS certificates and state

§bad_gateway_page: String

Path to custom 502 Bad Gateway HTML page

§http_port: u16

HTTP listen port

§https_port: u16

HTTPS listen port

§http_idle_timeout: Duration

HTTP idle timeout

§http_read_timeout: Duration

HTTP read timeout

§http_write_timeout: Duration

HTTP write timeout

§h2c_enabled: bool

Enable HTTP/2 cleartext (h2c) support for AWS ALB and Cloud Run

§forward_headers: bool

Forward X-Forwarded-* headers to upstream

§log_requests: bool

Enable request logging

§log_level: LogLevel

Log level

§shutdown_timeout_secs: u64

Graceful shutdown timeout in seconds

§database_url: Option<String>

PostgreSQL connection URL for coordination

§pg_channel_cache_invalidation: String

PostgreSQL NOTIFY channel for cache invalidation

§pg_channel_config_update: String

PostgreSQL NOTIFY channel for configuration updates

§pg_channel_health: String

PostgreSQL NOTIFY channel for health checks

§redis_url: Option<String>

Redis connection URL for distributed cache

§toml_config: Option<TomlConfig>

TOML configuration for advanced routing (None = simple mode)

§rate_limit_enabled: bool

Enable rate limiting per IP

§rate_limit_requests_per_sec: u32

Maximum requests per second per IP

§rate_limit_burst_size: u32

Rate limit burst size (tokens available immediately)

§upstream_timeout: Duration

Upstream request timeout

§circuit_breaker_enabled: bool

Enable circuit breaker

§circuit_breaker_failure_threshold: u32

Circuit breaker failure threshold (failures before opening)

§circuit_breaker_timeout_secs: u64

Circuit breaker timeout (seconds before trying half-open)

§max_concurrent_requests: usize

Maximum concurrent requests (0 = unlimited)

§metrics_enabled: bool

Enable Prometheus metrics endpoint

§metrics_port: u16

Port for Prometheus metrics HTTP server

§static_enabled: bool

Enable static file serving

§static_root: PathBuf

Root directory for static files

§static_paths: Vec<String>

URL paths that should be served as static files

§static_cache_control: String

Cache-Control header for static files

§static_gzip_enabled: bool

Enable gzip compression for static files

§static_index_files: Vec<String>

Index files to serve for directory requests

§static_fallthrough: bool

If true, continue to backend if static file not found; if false, return 404

§static_inline_size_limit: u64

Maximum file size to keep in memory (larger files are streamed)

§client_ip_header: Option<String>

Header name to extract real client IP from (e.g., “CF-Connecting-IP”, “X-Real-IP”)

§trusted_ranges_file: Option<PathBuf>

Path to file containing trusted IP ranges (CIDR format, one per line)

Implementations§

Source§

impl Config

Source

pub fn from_env() -> Result<Self, String>

Create configuration from environment variables

Loads configuration from environment variables, with support for both prefixed (WARPDRIVE_*) and unprefixed variables. Prefixed variables take precedence. Falls back to sensible defaults for all values.

§Errors

Returns an error if .env file exists but cannot be loaded.

§Example
use warpdrive::config::Config;

let config = Config::from_env().expect("Failed to load config");
Source

pub fn has_tls(&self) -> bool

Check if TLS is enabled

Returns true if either:

  • TLS certificate/key paths are provided (self-signed/manual), OR
  • At least one TLS domain is configured (ACME)
Source

pub fn has_manual_tls(&self) -> bool

Check if using manual TLS certificates (vs ACME)

Source

pub fn has_acme_domains(&self) -> bool

Check if ACME certificate provisioning is needed

Returns true if TLS domains are configured (without manual certs)

Source

pub fn validate(&self) -> Result<(), String>

Validate configuration

Performs validation checks on the configuration to ensure it’s internally consistent and meets requirements.

§Errors

Returns an error if:

  • TLS domains are specified without required ACME configuration
  • TLS certificate path specified without key path (or vice versa)
  • Ports are invalid (0 or above 65535)
  • Cache sizes are invalid
  • Database/Redis URLs are malformed

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,