Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions crates/factors-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl<T: RuntimeFactors, U: Send + 'static> FactorsExecutor<T, U> {
app: App,
runtime_config: T::RuntimeConfig,
component_loader: &impl ComponentLoader<T, U>,
trigger_type: Option<&str>,
) -> anyhow::Result<FactorsExecutorApp<T, U>> {
let configured_app = self
.factors
Expand All @@ -63,7 +64,14 @@ impl<T: RuntimeFactors, U: Send + 'static> FactorsExecutor<T, U> {
hooks.configure_app(&configured_app).await?;
}

let components = configured_app.app().components();
let components = match trigger_type {
Some(trigger_type) => configured_app
.app()
.triggers_with_type(trigger_type)
.filter_map(|t| t.component().ok())
.collect::<Vec<_>>(),
None => configured_app.app().components().collect(),
};
let mut component_instance_pres = HashMap::with_capacity(components.len());

for component in components {
Expand Down Expand Up @@ -334,7 +342,7 @@ mod tests {
let executor = Arc::new(FactorsExecutor::new(engine_builder, env.factors)?);

let factors_app = executor
.load_app(app, Default::default(), &DummyComponentLoader)
.load_app(app, Default::default(), &DummyComponentLoader, None)
.await?;

let mut instance_builder = factors_app.prepare("empty")?;
Expand Down
2 changes: 1 addition & 1 deletion crates/trigger/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ impl<T: Trigger<B::Factors>, B: RuntimeFactorsBuilder> TriggerAppBuilder<T, B> {
let configured_app = {
let _sloth_guard = warn_if_wasm_build_slothful();
executor
.load_app(app, runtime_config.into(), loader)
.load_app(app, runtime_config.into(), loader, Some(T::TYPE))
.await?
};

Expand Down
1 change: 1 addition & 0 deletions examples/spin-timer/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,29 @@ route = "/..."
Ok(())
}

#[test]
fn test_does_not_load_triggerless_component() -> anyhow::Result<()> {
run_test(
"unsupported-import-unused",
SpinConfig {
binary_path: spin_binary(),
spin_up_args: Vec::new(),
app_type: SpinAppType::Http,
},
ServicesConfig::none(),
move |env| {
let spin = env.runtime_mut();
assert_spin_request(
spin,
Request::full(Method::Get, "/", &[], Some("")),
Response::new_with_body(200, "Hello World!\n"),
)?;
Ok(())
},
)?;
Ok(())
}

#[test]
fn test_outbound_post() -> anyhow::Result<()> {
run_test(
Expand Down
Loading