Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move HandlerType to spin-http #2863

Merged
merged 3 commits into from
Sep 25, 2024
Merged

Move HandlerType to spin-http #2863

merged 3 commits into from
Sep 25, 2024

Conversation

rylev
Copy link
Collaborator

@rylev rylev commented Sep 25, 2024

This is useful functionality that other runtimes can use to determine which handler export they should call. In the future, we probably want to move calling of the right export completely into spin-http, but that can be done as a follow up.

@rylev rylev requested a review from lann September 25, 2024 11:42
@@ -211,6 +211,16 @@ impl<'a, T: RuntimeFactors, U> FactorsInstanceBuilder<'a, T, U> {
pub fn factor_builder<F: Factor>(&mut self) -> Option<&mut F::InstanceBuilder> {
self.factor_builders().for_factor::<F>()
}

/// Returns the underlying wasmtime engine for the instance.
pub fn engine(&self) -> &spin_core::wasmtime::Engine {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly confusing because in this same crate FactorsExecutorApp::engine() returns a spin_core::Engine. Maybe:

Suggested change
pub fn engine(&self) -> &spin_core::wasmtime::Engine {
pub fn wasmtime_engine(&self) -> &spin_core::wasmtime::Engine {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. The change seems like a fine one to make. While we're here though - a larger put perhaps cleaner change might be to rename spin_core::Engine to spin_core::WasmRuntime. This might be preferrable since even with your suggested change, a user still has to know how to disambiguate when a type signature includes an unqualified Engine.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe SpinEngine? "Runtime" is also awfully overloaded...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yet another alternative would be to re-export wasmtime::Engine as spin_core::WasmtimeEngine

@rylev rylev merged commit 5f992cf into main Sep 25, 2024
17 checks passed
percent-encoding = "2"
routefinder = "0.5.4"
serde = { workspace = true }
spin-app = { path = "../app", optional = true }
spin-locked-app = { path = "../locked-app" }
tracing = { workspace = true }
wasmtime = { workspace = true }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should, I think, be under the runtime feature. We have consumers of this crate who use it for things like route parsing (e.g. the cloud plugin), but do not want to drag the whole of wasmtime along with it.

(I'm happy if you prefer to reorganise things to avoid the feature thing, but I really really want a way for cloud-plugin to get what it needs without including wasmtime. Whether that is features or separate crates, I don't care, but it makes a big difference!)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I just tried updating cloud-plugin and it looks like some of the other recebt changes have also brought in wasmtime dependency. I'll get a PR out for all of it together.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I did some more investigation and I'm gonna punt on it for now. The wasmtime dependency makes 1 min of difference to a clean cloud-plugin build, but not enough difference to an incremental build to be worth the candle, and we are churning cloud-plugin dependencies a lot more slowly than when it drove me to extremes. Something to maybe think about how we can streamline in a more sustainable way in future, but not worth fretting about for now.

Sorry for bending your ear @rylev!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really good point, and something I would like to start getting a better handle on. Even though it doesn't make a huge difference, I can take a look at fixing this.

@rylev rylev deleted the more-http branch September 26, 2024 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants