Skip to content

Commit 402d9a6

Browse files
committed
Updated the return type in the 'trigger::run' func to use 'BoxFuture' for better async handling
Signed-off-by: Jiaxiao (mossaka) Zhou <[email protected]>
1 parent 8ed7418 commit 402d9a6

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

Cargo.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

containerd-shim-spin/src/engine.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
use std::{
2-
collections::{hash_map::DefaultHasher, HashSet},
3-
env,
4-
hash::{Hash, Hasher},
5-
};
1+
use std::{collections::HashSet, env, hash::Hash};
62

73
use anyhow::{Context, Result};
84
use containerd_shim_wasm::{
@@ -221,10 +217,8 @@ impl SpinSandbox {
221217
}
222218

223219
impl Compiler for SpinCompiler {
224-
fn cache_key(&self) -> impl Hash + Send {
225-
let mut hasher = DefaultHasher::new();
226-
self.0.precompile_compatibility_hash().hash(&mut hasher);
227-
hasher.finish()
220+
fn cache_key(&self) -> impl Hash {
221+
self.0.precompile_compatibility_hash()
228222
}
229223

230224
async fn compile(&self, layers: &[WasmLayer]) -> Result<Vec<Option<Vec<u8>>>> {

containerd-shim-spin/src/trigger.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
use std::{collections::HashSet, future::Future, path::Path, pin::Pin};
1+
use std::{collections::HashSet, path::Path};
22

3+
use anyhow::Result;
4+
use futures::{future::BoxFuture, FutureExt};
35
use log::info;
46
use spin_app::{locked::LockedApp, App};
57
use spin_runtime_factors::{FactorsBuilder, TriggerFactors};
@@ -27,7 +29,7 @@ pub(crate) async fn run<T>(
2729
cli_args: T::CliArgs,
2830
app: App,
2931
loader: &ComponentLoader,
30-
) -> anyhow::Result<Pin<Box<dyn Future<Output = anyhow::Result<()>> + Send>>>
32+
) -> Result<BoxFuture<'static, Result<()>>>
3133
where
3234
T: Trigger<TriggerFactors> + 'static,
3335
{
@@ -38,7 +40,7 @@ where
3840
let future = builder
3941
.run(app, factors_config(), Default::default(), loader)
4042
.await?;
41-
Ok(Box::pin(future))
43+
Ok(future.boxed())
4244
}
4345

4446
/// Configuration for the factors.

0 commit comments

Comments
 (0)