pub struct PingoraPlugin { /* private fields */ }Expand description
Runs a Pingora reverse proxy inside an Autumn app.
use autumn_plugin_pingora::{PingoraPlugin, Route};
autumn_web::app()
.routes(routes![index])
.plugin(PingoraPlugin::new().route(
Route::new("billing").path_prefix("/billing").upstream("10.0.0.7:8080"),
))
.run()
.await;The plugin reads [pingora] from autumn.toml (see PingoraConfig).
Fluent setters apply on top of the file values.
On boot, the plugin:
- resolves the upstreams,
- binds the listener (a failure stops boot),
- starts the health checks,
- adds a
pingorahealth indicator andpingora_proxy_*metrics, - puts a
PingoraHandleintoAppState.
The plugin drains when Autumn’s shutdown signal fires.
Implementations§
Source§impl PingoraPlugin
impl PingoraPlugin
Sourcepub fn configure(
self,
apply: impl Fn(&mut PingoraConfig) + Send + Sync + 'static,
) -> Self
pub fn configure( self, apply: impl Fn(&mut PingoraConfig) + Send + Sync + 'static, ) -> Self
Change the configuration in code, after files and environment.
Sourcepub fn config(self, config: PingoraConfig) -> Self
pub fn config(self, config: PingoraConfig) -> Self
Use config and read no config files. The profile still comes from
the environment (see development). Fluent
setters still apply on top.
Sourcepub fn development(self, development: bool) -> Self
pub fn development(self, development: bool) -> Self
Force development (true) or production (false) defaults. By
default, the active profile decides.
Sourcepub const fn public(self) -> Self
pub const fn public(self) -> Self
Mark the proxied prefixes as public in autumn routes. If you do
not, they are unclassified. Then autumn routes audit fails.
Sourcepub fn handle(&self) -> PingoraHandle
pub fn handle(&self) -> PingoraHandle
A handle to this plugin’s proxy. It is valid before and after boot.
Sourcepub fn route_infos(&self) -> Vec<RouteInfo>
pub fn route_infos(&self) -> Vec<RouteInfo>
The proxied prefixes as autumn routes lists them: method PROXY,
path [host]/prefix/*. The fallback is not listed: the app routes
cover it.
Sourcepub fn effective_config(&self) -> Result<&PingoraConfig, &ConfigError>
pub fn effective_config(&self) -> Result<&PingoraConfig, &ConfigError>
Trait Implementations§
Source§impl Debug for PingoraPlugin
impl Debug for PingoraPlugin
Source§impl Default for PingoraPlugin
impl Default for PingoraPlugin
Source§impl Plugin for PingoraPlugin
impl Plugin for PingoraPlugin
Source§fn name(&self) -> Cow<'static, str>
fn name(&self) -> Cow<'static, str>
Source§fn build(self, app: AppBuilder) -> AppBuilder
fn build(self, app: AppBuilder) -> AppBuilder
Auto Trait Implementations§
impl !Freeze for PingoraPlugin
impl !RefUnwindSafe for PingoraPlugin
impl !UnwindSafe for PingoraPlugin
impl Forget for PingoraPlugin
impl Send for PingoraPlugin
impl Sync for PingoraPlugin
impl Unpin for PingoraPlugin
impl UnsafeUnpin for PingoraPlugin
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<P> Plugins for Pwhere
P: Plugin,
impl<P> Plugins for Pwhere
P: Plugin,
Source§fn apply(self, app: AppBuilder) -> AppBuilder
fn apply(self, app: AppBuilder) -> AppBuilder
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.