g3proxy: use less allocation when publish data to escaper
Some checks are pending
Linux-CI / Build vendored-2 (push) Waiting to run
Linux-CI / Build vendored-3 (push) Waiting to run
Linux-CI / Build vendored-4 (push) Waiting to run
Linux-CI / Build vendored-5 (push) Waiting to run
CodeCoverage / g3bench test (push) Waiting to run
CodeCoverage / g3statsd test (push) Waiting to run
CodeCoverage / lib unit test (push) Waiting to run
CodeCoverage / g3mkcert test (push) Waiting to run
CodeCoverage / g3keymess test (push) Waiting to run
CodeCoverage / g3proxy test (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (java-kotlin) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
CodeQL Advanced / Analyze (rust) (push) Waiting to run
CrossCompiling / Build (push) Waiting to run
CrossCompiling / Build-1 (push) Waiting to run
CrossCompiling / Build-2 (push) Waiting to run
CrossCompiling / Build-3 (push) Waiting to run
CrossCompiling / Build-4 (push) Waiting to run
CrossCompiling / Build-5 (push) Waiting to run
CrossCompiling / Build-6 (push) Waiting to run
CrossCompiling / Build-7 (push) Waiting to run
CrossCompiling / Build-8 (push) Waiting to run
CrossCompiling / Build-9 (push) Waiting to run
Linux-CI / Build (push) Waiting to run
Linux-CI / Build-1 (push) Waiting to run
Linux-CI / Build-2 (push) Waiting to run
Linux-CI / Build-3 (push) Waiting to run
Linux-CI / Clippy (push) Waiting to run
Linux-CI / Build vendored (push) Waiting to run
Linux-CI / Build vendored-1 (push) Waiting to run
Linux-CI / Build vendored-26 (push) Waiting to run
Linux-CI / Build vendored-6 (push) Waiting to run
Linux-CI / Build vendored-7 (push) Waiting to run
Linux-CI / Build vendored-8 (push) Waiting to run
Linux-CI / Build vendored-9 (push) Waiting to run
Linux-CI / Build vendored-10 (push) Waiting to run
Linux-CI / Build vendored-11 (push) Waiting to run
Linux-CI / Build vendored-12 (push) Waiting to run
Linux-CI / Build vendored-13 (push) Waiting to run
Linux-CI / Build vendored-14 (push) Waiting to run
Linux-CI / Build vendored-15 (push) Waiting to run
Linux-CI / Build vendored-16 (push) Waiting to run
Linux-CI / Build vendored-17 (push) Waiting to run
Linux-CI / Build vendored-18 (push) Waiting to run
Linux-CI / Build vendored-19 (push) Waiting to run
Linux-CI / Build vendored-20 (push) Waiting to run
Linux-CI / Build vendored-21 (push) Waiting to run
Linux-CI / Build vendored-22 (push) Waiting to run
Linux-CI / Build vendored-23 (push) Waiting to run
Linux-CI / Build vendored-24 (push) Waiting to run
Linux-CI / Build vendored-25 (push) Waiting to run
Linux-CI / Build vendored-27 (push) Waiting to run
Linux-CI / Build vendored-28 (push) Waiting to run
Linux-CI / Build vendored-29 (push) Waiting to run
Linux-CI / Build vendored-30 (push) Waiting to run
Linux-CI / Build with OpenSSL Async Job (push) Waiting to run
Linux-CI / Build with OpenSSL Async Job-1 (push) Waiting to run
MacOS-CI / Build (push) Waiting to run
MacOS-CI / Build vendored (push) Waiting to run
MacOS-CI / Build vendored-1 (push) Waiting to run
MacOS-CI / Build vendored-2 (push) Waiting to run
MacOS-CI / Build vendored-3 (push) Waiting to run
MacOS-CI / Build vendored-4 (push) Waiting to run
MacOS-CI / Build vendored-5 (push) Waiting to run
MacOS-CI / Build vendored-6 (push) Waiting to run
MacOS-CI / Build vendored-7 (push) Waiting to run
MacOS-CI / Build vendored-8 (push) Waiting to run
MacOS-CI / Build vendored-9 (push) Waiting to run
MacOS-CI / Build vendored-10 (push) Waiting to run
MacOS-CI / Build vendored-11 (push) Waiting to run
MacOS-CI / Build vendored-12 (push) Waiting to run
MacOS-CI / Build vendored-13 (push) Waiting to run
MacOS-CI / Build vendored-14 (push) Waiting to run
MacOS-CI / Build vendored-15 (push) Waiting to run
MacOS-CI / Build vendored-16 (push) Waiting to run
MacOS-CI / Build vendored-17 (push) Waiting to run
MacOS-CI / Build vendored-18 (push) Waiting to run
MacOS-CI / Build vendored-19 (push) Waiting to run
MacOS-CI / Build vendored-20 (push) Waiting to run
MacOS-CI / Build vendored-21 (push) Waiting to run
MacOS-CI / Build vendored-22 (push) Waiting to run
MacOS-CI / Build vendored-23 (push) Waiting to run
MacOS-CI / Build vendored-24 (push) Waiting to run
StaticLinking / musl (push) Waiting to run
StaticLinking / musl-1 (push) Waiting to run
StaticLinking / msvc-vcpkg (push) Waiting to run
StaticLinking / msvc-vendored (push) Waiting to run
StaticLinking / msvc-vendored-1 (push) Waiting to run
StaticLinking / msvc-vendored-2 (push) Waiting to run
StaticLinking / msvc-vendored-3 (push) Waiting to run
Windows-CI / Build (push) Waiting to run
Windows-CI / Build vendored (push) Waiting to run
Windows-CI / Build vendored-1 (push) Waiting to run
Windows-CI / Build vendored-2 (push) Waiting to run
Windows-CI / Build vendored-3 (push) Waiting to run
Windows-CI / Build vendored-4 (push) Waiting to run
Windows-CI / Build vendored-5 (push) Waiting to run
Windows-CI / Build vendored-6 (push) Waiting to run
Windows-CI / Build vendored-7 (push) Waiting to run
Windows-CI / Build vendored-8 (push) Waiting to run
Windows-CI / Build vendored-9 (push) Waiting to run
Windows-CI / Build vendored-10 (push) Waiting to run
Windows-CI / Build vendored-11 (push) Waiting to run
Windows-CI / Build vendored-12 (push) Waiting to run
Windows-CI / Build vendored-13 (push) Waiting to run
Windows-CI / Build vendored-14 (push) Waiting to run
Windows-CI / Build vendored-15 (push) Waiting to run
Windows-CI / Build vendored-16 (push) Waiting to run
Windows-CI / Build vendored-17 (push) Waiting to run
Windows-CI / Build vendored-18 (push) Waiting to run
Windows-CI / Build vendored-19 (push) Waiting to run
Windows-CI / Build vendored-20 (push) Waiting to run
Windows-CI / Build vendored-21 (push) Waiting to run
Windows-CI / Build vendored-22 (push) Waiting to run
Windows-CI / Build vendored-23 (push) Waiting to run

This commit is contained in:
Zhang Jingqiang 2025-10-28 09:05:24 +08:00
parent a784d24656
commit 26d8a090ff
23 changed files with 25 additions and 25 deletions

View file

@ -28,7 +28,7 @@ impl escaper_control::Server for EscaperControlImpl {
params: escaper_control::PublishParams,
mut results: escaper_control::PublishResults,
) -> capnp::Result<()> {
let data = params.get()?.get_data()?.to_string()?;
let data = params.get()?.get_data()?.to_str()?;
let r = self.escaper.publish(data).await;
set_operation_result(results.get().init_result(), r);
Ok(())

View file

@ -94,7 +94,7 @@ impl Escaper for ComplyAuditEscaper {
Some(&self.stats)
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -291,7 +291,7 @@ impl Escaper for DirectFixedEscaper {
Some(self.stats.clone())
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -337,7 +337,7 @@ impl Escaper for DirectFloatEscaper {
Some(Arc::clone(&self.stats) as ArcEscaperStats)
}
async fn publish(&self, data: String) -> anyhow::Result<()> {
async fn publish(&self, data: &str) -> anyhow::Result<()> {
publish::publish_records(&self.config, &self.bind_v4, &self.bind_v6, data).await
}

View file

@ -93,10 +93,10 @@ pub(super) async fn publish_records(
config: &DirectFloatEscaperConfig,
v4_container: &ArcSwap<BindSet>,
v6_container: &ArcSwap<BindSet>,
data: String,
data: &str,
) -> anyhow::Result<()> {
let obj =
Value::from_str(&data).map_err(|e| anyhow!("the input data is not valid json: {:?}", e))?;
Value::from_str(data).map_err(|e| anyhow!("the input data is not valid json: {:?}", e))?;
if let Value::Object(map) = obj {
for (k, v) in map.into_iter() {

View file

@ -196,7 +196,7 @@ impl Escaper for DivertTcpEscaper {
Some(self.stats.clone())
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -86,7 +86,7 @@ impl Escaper for DummyDenyEscaper {
Some(self.stats.clone())
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -157,7 +157,7 @@ pub(crate) trait Escaper: EscaperInternal {
None
}
async fn publish(&self, data: String) -> anyhow::Result<()>;
async fn publish(&self, data: &str) -> anyhow::Result<()>;
async fn tcp_setup_connection(
&self,

View file

@ -175,7 +175,7 @@ impl Escaper for ProxyFloatEscaper {
Some(self.stats.clone())
}
async fn publish(&self, data: String) -> anyhow::Result<()> {
async fn publish(&self, data: &str) -> anyhow::Result<()> {
source::publish_peers(&self.config, &self.peers, data).await
}

View file

@ -49,9 +49,9 @@ async fn parse_and_save_peers(
pub(super) async fn publish_peers(
config: &ProxyFloatEscaperConfig,
peers_container: &Arc<ArcSwap<PeerSet>>,
data: String,
data: &str,
) -> anyhow::Result<()> {
let obj = serde_json::from_str(&data)
let obj = serde_json::from_str(data)
.map_err(|e| anyhow!("the publish data is not valid json: {e:?}"))?;
let records = match obj {
serde_json::Value::Array(v) => v,

View file

@ -166,7 +166,7 @@ impl Escaper for ProxyHttpEscaper {
Some(self.stats.clone())
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -175,7 +175,7 @@ impl Escaper for ProxyHttpsEscaper {
Some(self.stats.clone())
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -166,7 +166,7 @@ impl Escaper for ProxySocks5Escaper {
Some(Arc::clone(&self.stats) as ArcEscaperStats)
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -174,7 +174,7 @@ impl Escaper for ProxySocks5sEscaper {
Some(Arc::clone(&self.stats) as ArcEscaperStats)
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -139,7 +139,7 @@ impl Escaper for RouteClientEscaper {
Some(&self.stats)
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -104,7 +104,7 @@ impl Escaper for RouteFailoverEscaper {
Some(&self.stats)
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -240,7 +240,7 @@ impl Escaper for RouteGeoIpEscaper {
Some(&self.stats)
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -112,7 +112,7 @@ impl Escaper for RouteMappingEscaper {
Some(&self.stats)
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -136,7 +136,7 @@ impl Escaper for RouteQueryEscaper {
Some(&self.stats)
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -161,7 +161,7 @@ impl Escaper for RouteResolvedEscaper {
Some(&self.stats)
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -145,7 +145,7 @@ impl Escaper for RouteSelectEscaper {
Some(&self.stats)
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -164,7 +164,7 @@ impl Escaper for RouteUpstreamEscaper {
Some(&self.stats)
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}

View file

@ -111,7 +111,7 @@ impl Escaper for TrickFloatEscaper {
Some(&self.stats)
}
async fn publish(&self, _data: String) -> anyhow::Result<()> {
async fn publish(&self, _data: &str) -> anyhow::Result<()> {
Err(anyhow!("not implemented"))
}