Skip to content

Commit 3b673a9

Browse files
committed
refactor: remove redundant variables
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
1 parent fad6827 commit 3b673a9

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

crates/host/src/wasmbus/providers/http_server/address.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,17 @@ impl wasmcloud_provider_sdk::Provider for Provider {
4646
let ServiceSettings { address, .. } =
4747
load_settings(Some(self.address), config).context("failed to load settings")?;
4848

49-
let lattice_id = Arc::clone(&self.lattice_id);
50-
let host_id = Arc::clone(&self.host_id);
5149
let components = Arc::clone(&self.components);
50+
let host_id = Arc::clone(&self.host_id);
51+
let lattice_id = Arc::clone(&self.lattice_id);
5252
let target_id: Arc<str> = Arc::from(target_id);
53-
// Annoyingly, we have to declare a separate clone of the target_id for the closure
54-
let target_id_closure = Arc::clone(&target_id);
55-
let tasks = listen(
56-
address,
53+
let tasks = listen(address, {
54+
let target_id = Arc::clone(&target_id);
5755
move |req: hyper::Request<hyper::body::Incoming>| {
58-
let target_id = Arc::clone(&target_id_closure);
59-
let lattice_id = Arc::clone(&lattice_id);
60-
let host_id = Arc::clone(&host_id);
6156
let components = Arc::clone(&components);
57+
let host_id = Arc::clone(&host_id);
58+
let lattice_id = Arc::clone(&lattice_id);
59+
let target_id = Arc::clone(&target_id);
6260
async move {
6361
let component = {
6462
let components = components.read().await;
@@ -133,8 +131,8 @@ impl wasmcloud_provider_sdk::Provider for Provider {
133131
anyhow::Ok(res)
134132
}
135133
.instrument(info_span!("handle"))
136-
},
137-
)
134+
}
135+
})
138136
.await?;
139137

140138
self.links

crates/host/src/wasmbus/providers/http_server/path.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,13 @@ impl Provider {
128128
host_id: Arc<str>,
129129
) -> anyhow::Result<Self> {
130130
let path_router: Arc<RwLock<Router>> = Arc::default();
131-
132-
// Annoyingly, we have to declare a separate clone of the path_router for the closure
133-
let path_router_closure = Arc::clone(&path_router);
134-
let handle = listen(
135-
address,
131+
let handle = listen(address, {
132+
let path_router = Arc::clone(&path_router);
136133
move |req: hyper::Request<hyper::body::Incoming>| {
137134
let lattice_id = Arc::clone(&lattice_id);
138135
let host_id = Arc::clone(&host_id);
139136
let components = Arc::clone(&components);
140-
let path_router = Arc::clone(&path_router_closure);
137+
let path_router = Arc::clone(&path_router);
141138
async move {
142139
let (
143140
http::request::Parts {
@@ -234,8 +231,8 @@ impl Provider {
234231
anyhow::Ok(res)
235232
}
236233
.instrument(info_span!("handle"))
237-
},
238-
)
234+
}
235+
})
239236
.await
240237
.context("failed to listen on address for path based http server")?;
241238

0 commit comments

Comments
 (0)