pub struct Upstream {
pub name: String,
pub key: String,
/* private fields */
}Expand description
Represents a group of backend servers and their configuration for load balancing and connection management
Fields§
§name: StringUnique identifier for this upstream group
key: StringHash key used to detect configuration changes
Implementations§
Source§impl Upstream
impl Upstream
Sourcepub fn new(
name: &str,
conf: &UpstreamConf,
sender: Option<Arc<NotificationSender>>,
) -> Result<Self, Error>
pub fn new( name: &str, conf: &UpstreamConf, sender: Option<Arc<NotificationSender>>, ) -> Result<Self, Error>
Sourcepub fn new_http_peer(
&self,
session: &Session,
client_ip: &Option<String>,
) -> Option<HttpPeer>
pub fn new_http_peer( &self, session: &Session, client_ip: &Option<String>, ) -> Option<HttpPeer>
Creates and configures a new HTTP peer for handling requests
§Arguments
session- Current HTTP session containing request detailsctx- Request context state
§Returns
Option<HttpPeer>- Configured HTTP peer if a healthy backend is available, None otherwise
This method:
- Selects an appropriate backend using the configured load balancing strategy
- Increments the processing counter
- Creates and configures an HttpPeer with the connection settings
Sourcepub fn connected(&self) -> Option<i32>
pub fn connected(&self) -> Option<i32>
Returns the current number of active connections to this upstream
§Returns
Option<i32>- Number of active connections if tracking is enabled, None otherwise
Sourcepub fn as_round_robin(&self) -> Option<Arc<LoadBalancer<RoundRobin>>>
pub fn as_round_robin(&self) -> Option<Arc<LoadBalancer<RoundRobin>>>
Returns the round-robin load balancer if configured
§Returns
Option<Arc<LoadBalancer<RoundRobin>>>- Round-robin load balancer if used, None otherwise
Sourcepub fn as_consistent(&self) -> Option<Arc<LoadBalancer<Consistent>>>
pub fn as_consistent(&self) -> Option<Arc<LoadBalancer<Consistent>>>
Returns the consistent hash load balancer if configured
§Returns
Option<Arc<LoadBalancer<Consistent>>>- Consistent hash load balancer if used, None otherwise
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Upstream
impl !RefUnwindSafe for Upstream
impl Send for Upstream
impl Sync for Upstream
impl Unpin for Upstream
impl !UnwindSafe for Upstream
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
Mutably borrows from an owned value. Read more
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<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request