pub struct ProxyServiceBuilder<SV, C>where
SV: ProxyHttp + Send + Sync + 'static,
<SV as ProxyHttp>::CTX: Send + Sync + 'static,
C: Connector,{ /* private fields */ }proxy only.Expand description
A builder for a Service that can be used to create a HttpProxy instance
The ProxyServiceBuilder can be used to construct a HttpProxy service with a custom name, connector, and custom session handler.
Implementations§
Source§impl<SV> ProxyServiceBuilder<SV, ()>
impl<SV> ProxyServiceBuilder<SV, ()>
Sourcepub fn new(conf: &Arc<ServerConf>, inner: SV) -> ProxyServiceBuilder<SV, ()>
pub fn new(conf: &Arc<ServerConf>, inner: SV) -> ProxyServiceBuilder<SV, ()>
Create a new ProxyServiceBuilder with the given ServerConf and ProxyHttp implementation.
The returned builder can be used to construct a HttpProxy service with a custom name, connector, and custom session handler.
The ProxyServiceBuilder will default to using the ProxyHttp implementation and no custom session handler.
Source§impl<SV, C> ProxyServiceBuilder<SV, C>
impl<SV, C> ProxyServiceBuilder<SV, C>
Sourcepub fn name(self, name: impl AsRef<str>) -> ProxyServiceBuilder<SV, C>
pub fn name(self, name: impl AsRef<str>) -> ProxyServiceBuilder<SV, C>
Sets the name of the HttpProxy service.
Sourcepub fn custom<C2>(
self,
connector: C2,
on_custom: Arc<dyn Fn(Arc<HttpProxy<SV, C2>>, Box<dyn IO>, &Receiver<bool>) -> Pin<Box<dyn Future<Output = Option<Box<dyn IO>>> + Send>> + Sync + Send + Unpin>,
) -> ProxyServiceBuilder<SV, C2>where
C2: Connector,
pub fn custom<C2>(
self,
connector: C2,
on_custom: Arc<dyn Fn(Arc<HttpProxy<SV, C2>>, Box<dyn IO>, &Receiver<bool>) -> Pin<Box<dyn Future<Output = Option<Box<dyn IO>>> + Send>> + Sync + Send + Unpin>,
) -> ProxyServiceBuilder<SV, C2>where
C2: Connector,
Set a custom connector and custom session handler for the ProxyServiceBuilder.
The custom connector is used to establish a connection to the upstream server.
The custom session handler is used to handle custom protocol specific logic between the proxy and the upstream server.
Returns a new ProxyServiceBuilder with the custom connector and session handler.
Sourcepub fn server_options(
self,
options: HttpServerOptions,
) -> ProxyServiceBuilder<SV, C>
pub fn server_options( self, options: HttpServerOptions, ) -> ProxyServiceBuilder<SV, C>
Set the server options for the ProxyServiceBuilder.
Returns a new ProxyServiceBuilder with the server options set.
Sourcepub fn build(self) -> Service<HttpProxy<SV, C>>
pub fn build(self) -> Service<HttpProxy<SV, C>>
Builds a new Service from the ProxyServiceBuilder.
This function takes ownership of the ProxyServiceBuilder and returns a new Service with a fully initialized HttpProxy.
The returned Service is ready to be used by a pingora_core::server::Server.