mirror of
https://github.com/sadoyan/aralez.git
synced 2026-05-30 03:44:06 +08:00
cleanups
This commit is contained in:
@@ -83,7 +83,6 @@ pub struct Auth {
|
|||||||
pub struct PathConfig {
|
pub struct PathConfig {
|
||||||
pub servers: Vec<String>,
|
pub servers: Vec<String>,
|
||||||
pub to_https: Option<bool>,
|
pub to_https: Option<bool>,
|
||||||
pub sticky_sessions: Option<bool>,
|
|
||||||
pub client_headers: Option<Vec<String>>,
|
pub client_headers: Option<Vec<String>>,
|
||||||
pub server_headers: Option<Vec<String>>,
|
pub server_headers: Option<Vec<String>>,
|
||||||
pub rate_limit: Option<isize>,
|
pub rate_limit: Option<isize>,
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ pub struct LB {
|
|||||||
|
|
||||||
pub struct Context {
|
pub struct Context {
|
||||||
backend_id: Option<String>,
|
backend_id: Option<String>,
|
||||||
sticky_sessions: Option<u64>,
|
|
||||||
start_time: Instant,
|
start_time: Instant,
|
||||||
hostname: Option<Arc<str>>,
|
hostname: Option<Arc<str>>,
|
||||||
upstream_peer: Option<Arc<InnerMap>>,
|
upstream_peer: Option<Arc<InnerMap>>,
|
||||||
@@ -53,7 +52,6 @@ impl ProxyHttp for LB {
|
|||||||
fn new_ctx(&self) -> Self::CTX {
|
fn new_ctx(&self) -> Self::CTX {
|
||||||
Context {
|
Context {
|
||||||
backend_id: None,
|
backend_id: None,
|
||||||
sticky_sessions: None,
|
|
||||||
start_time: Instant::now(),
|
start_time: Instant::now(),
|
||||||
hostname: None,
|
hostname: None,
|
||||||
upstream_peer: None,
|
upstream_peer: None,
|
||||||
@@ -98,7 +96,9 @@ impl ProxyHttp for LB {
|
|||||||
let header = ResponseHeader::build(429, None)?;
|
let header = ResponseHeader::build(429, None)?;
|
||||||
session.set_keepalive(None);
|
session.set_keepalive(None);
|
||||||
session.write_response_header(Box::new(header), true).await?;
|
session.write_response_header(Box::new(header), true).await?;
|
||||||
debug!("Rate limited: {:?}, {}", rate_key, rate);
|
if let (Some(oi), Some(oa)) = (&_ctx.hostname, rate_key) {
|
||||||
|
warn!("Limit: {}-rps exceed on {} from {}", rate, oi, oa);
|
||||||
|
}
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,6 @@ impl ProxyHttp for LB {
|
|||||||
)
|
)
|
||||||
.unwrap_or(());
|
.unwrap_or(());
|
||||||
ctx.backend_id = Some(s);
|
ctx.backend_id = Some(s);
|
||||||
ctx.sticky_sessions = ctx.extraparams.sticky_sessions;
|
|
||||||
}
|
}
|
||||||
Ok(peer)
|
Ok(peer)
|
||||||
}
|
}
|
||||||
@@ -236,7 +235,7 @@ impl ProxyHttp for LB {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
async fn response_filter(&self, _session: &mut Session, _upstream_response: &mut ResponseHeader, ctx: &mut Self::CTX) -> Result<()> {
|
async fn response_filter(&self, _session: &mut Session, _upstream_response: &mut ResponseHeader, ctx: &mut Self::CTX) -> Result<()> {
|
||||||
if let Some(val) = ctx.sticky_sessions {
|
if let Some(val) = ctx.extraparams.sticky_sessions {
|
||||||
if let Some(bid) = &ctx.backend_id {
|
if let Some(bid) = &ctx.backend_id {
|
||||||
let tt = if let Some(existing) = REVERSE_STORE.get(bid) {
|
let tt = if let Some(existing) = REVERSE_STORE.get(bid) {
|
||||||
existing.value().clone()
|
existing.value().clone()
|
||||||
|
|||||||
Reference in New Issue
Block a user