Skip to main content

PingoraConfig

Struct PingoraConfig 

Source
#[non_exhaustive]
pub struct PingoraConfig {
Show 16 fields pub enabled: bool, pub bind: String, pub fallback: Fallback, pub trusted_proxies: Vec<String>, pub connect_timeout_ms: u64, pub read_timeout_ms: u64, pub write_timeout_ms: u64, pub max_retries: usize, pub health_check_interval_ms: u64, pub health_check_timeout_ms: u64, pub max_request_body_bytes: u64, pub max_connections: usize, pub max_connections_per_ip: usize, pub shutdown_grace_ms: u64, pub metrics: bool, pub routes: Vec<Route>,
}
Expand description

Settings for the proxy.

For a setting that says “0: off”, the value 0 removes that limit.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§enabled: bool

Start the proxy. Default: true.

§bind: String

Listen address, IP:port. Port 0 picks a free port. Empty: the profile decides. dev and test use 127.0.0.1:8080. Other profiles use 0.0.0.0:8080. Default: empty.

§fallback: Fallback

Where unmatched requests go: app (the Autumn app) or none (404). Default: app.

§trusted_proxies: Vec<String>

Peers (IPs or CIDR ranges) whose X-Forwarded-* and other identity headers the proxy keeps. For other peers, the proxy replaces them. Put only your own load balancers here. Default: empty.

§connect_timeout_ms: u64

Upstream connect timeout. Must be more than 0. Default: 5000.

§read_timeout_ms: u64

Upstream read timeout. 0: off. Default: 60000.

§write_timeout_ms: u64

Upstream write timeout. 0: off. Default: 60000.

§max_retries: usize

Connect retries on another upstream. Pingora also retries an idempotent request once or twice when a pooled connection is stale. Default: 1.

§health_check_interval_ms: u64

Upstream TCP health check interval. 0: off. Default: 5000.

§health_check_timeout_ms: u64

Health check connect timeout. Must be more than 0. Default: 1000.

§max_request_body_bytes: u64

Largest request body. Bigger requests get 413. 0: off. Default: 10485760 (10 MiB).

§max_connections: usize

Maximum open client connections. At the limit, the proxy stops accepting until a connection closes. 0: no limit. At most 1000000. Default: 10000.

§max_connections_per_ip: usize

Maximum open connections from one client IP. The proxy closes connections over the limit at once. Keep 0 behind a load balancer, because all connections then have its IP. 0: no limit. Default: 0.

§shutdown_grace_ms: u64

Time for open requests to finish at shutdown. Must be more than 0. The plugin caps it to fit server.shutdown_timeout_secs. Default: 10000.

§metrics: bool

Record pingora_proxy_* metrics. Default: true.

§routes: Vec<Route>

The routes. Env: AUTUMN_PINGORA__ROUTES replaces all routes with a TOML array.

Implementations§

Source§

impl PingoraConfig

Source

pub fn bind_addr(&self, development: bool) -> Result<SocketAddr, ConfigError>

The listen address. An empty bind gives 127.0.0.1:8080 in development and 0.0.0.0:8080 in other profiles.

§Errors

Returns ConfigError when bind is not IP:port.

Source

pub const fn connect_timeout(&self) -> Duration

Upstream connect timeout.

Source

pub const fn read_timeout(&self) -> Option<Duration>

Upstream read timeout.

Source

pub const fn write_timeout(&self) -> Option<Duration>

Upstream write timeout.

Source

pub const fn health_check_interval(&self) -> Option<Duration>

Health check interval.

Source

pub const fn health_check_timeout(&self) -> Duration

Health check connect timeout.

Source

pub const fn shutdown_grace(&self) -> Duration

Shutdown grace period.

Source

pub fn from_toml_str(text: &str, section: &str) -> Result<Self, ConfigError>

Parse [section] from a whole autumn.toml text. No profiles and no environment.

§Errors

Returns ConfigError for bad TOML, unknown keys, wrong types or values that validate rejects.

Source

pub fn resolve(section: &str) -> Result<Resolved, ConfigError>

Resolve [section] from the app’s files and the process environment.

§Errors

Returns ConfigError when a file cannot be read or parsed, or when the merged section is not valid.

Source

pub fn resolve_with_env( section: &str, env: &dyn Env, ) -> Result<Resolved, ConfigError>

Like resolve, but reads only env.

§Errors

See resolve.

Source

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

Reject values that fail at runtime.

§Errors

Returns ConfigError that names the bad key.

Trait Implementations§

Source§

impl Clone for PingoraConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PingoraConfig

Source§

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

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

impl Default for PingoraConfig

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for PingoraConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for PingoraConfig

Source§

impl PartialEq for PingoraConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PingoraConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PingoraConfig

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> JsonSink for T
where T: Serialize + ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scoped for T
where T: Send + Sync + 'static,

Source§

fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>

Open a deferred ScopeQuery for this type. Resolves the registered scope at .load() time, not here.
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 = !

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

fn try_from(value: U) -> Result<T, !>

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