-
Notifications
You must be signed in to change notification settings - Fork 247
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
[Factors] in-process runtime and conformance tests #2732
Conversation
Signed-off-by: Ryan Levick <[email protected]>
Signed-off-by: Ryan Levick <[email protected]>
crates/trigger-http2/src/server.rs
Outdated
@@ -333,6 +288,111 @@ impl HttpServer { | |||
} | |||
} | |||
|
|||
/// Handles a routed HTTP trigger request. | |||
pub struct RequestHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you say more about this change? It isn't clear how it relates to the conformance tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be fair this was from an evolutionary dead end. I do think it helps make things a bit easier to follow (at the expense of being slightly more verbose) by only giving the OutboundHttpInterceptor
what it needs and nothing more. It encapsulates just the component handling and leaves out all the other HTTP sever stuff to the encapsulating HttpServer
types.
I can revert it if you want me to though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its mostly just really hard to review the diff 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry! If you aren't able to review, I'll revert that change tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reverted that change so hopefully the diff is a bit easier to read. Unfortunately, there's one spot where git's diffing still gets a bit confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Signed-off-by: Ryan Levick <[email protected]>
363e400
to
32f6da4
Compare
let (abortable, abort_handle) = futures::future::abortable(run_fut); | ||
ctrlc::set_handler(move || abort_handle.abort())?; | ||
match abortable.await { | ||
Ok(Ok(())) => { | ||
tracing::info!("Trigger executor shut down: exiting"); | ||
Ok(()) | ||
} | ||
Ok(Err(err)) => { | ||
tracing::error!("Trigger executor failed"); | ||
Err(err) | ||
} | ||
Err(_aborted) => { | ||
tracing::info!("User requested shutdown: exiting"); | ||
Ok(()) | ||
} | ||
} | ||
} | ||
|
||
fn follow_components(&self) -> FollowComponents { | ||
if self.silence_component_logs { | ||
FollowComponents::None | ||
} else if self.follow_components.is_empty() { | ||
FollowComponents::All | ||
} else { | ||
let followed = self.follow_components.clone().into_iter().collect(); | ||
FollowComponents::Named(followed) | ||
} | ||
} | ||
} | ||
|
||
const SLOTH_WARNING_DELAY_MILLIS: u64 = 1250; | ||
|
||
fn warn_if_wasm_build_slothful() -> sloth::SlothGuard { | ||
#[cfg(debug_assertions)] | ||
let message = "\ | ||
This is a debug build - preparing Wasm modules might take a few seconds\n\ | ||
If you're experiencing long startup times please switch to the release build"; | ||
|
||
#[cfg(not(debug_assertions))] | ||
let message = "Preparing Wasm modules is taking a few seconds..."; | ||
|
||
sloth::warn_if_slothful(SLOTH_WARNING_DELAY_MILLIS, format!("{message}\n")) | ||
} | ||
|
||
fn help_heading<T: Trigger>() -> Option<&'static str> { | ||
if T::TYPE == help::HelpArgsOnlyTrigger::TYPE { | ||
Some("TRIGGER OPTIONS") | ||
} else { | ||
let heading = format!("{} TRIGGER OPTIONS", T::TYPE.to_uppercase()); | ||
let as_str = Box::new(heading).leak(); | ||
Some(as_str) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all just moved from down below.
crates/trigger-http2/src/server.rs
Outdated
@@ -333,6 +288,111 @@ impl HttpServer { | |||
} | |||
} | |||
|
|||
/// Handles a routed HTTP trigger request. | |||
pub struct RequestHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reverted that change so hopefully the diff is a bit easier to read. Unfortunately, there's one spot where git's diffing still gets a bit confused.
This allows us to run runtime and conformance tests using the "in-process runtime" (as opposed to the Spin CLI spawned process runtime).
This requires a few refactorings that I think push us more towards other goals as well (namely spin-trigger being generic over the
RuntimeFactors
type).The actual code for instantiating and triggering an HTTP trigger without running an actual HTTP server looks like this: