-
Notifications
You must be signed in to change notification settings - Fork 257
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
Service chaining #2305
Service chaining #2305
Conversation
859021d
to
e8aad87
Compare
@lann This has a proposal for the lockfile stuff, which declares v0 and v1 serialisation formats plus a new wrapper that handles deserialisation from either format and serialisation to the v0 or v1 format depending on whether v1 features are needed. The wrapper format is no longer |
I had been thinking that the version field could just be relaxed to allow 0 or 1 since the format is (syntactically) backward-compatible. |
@lann That would work for deserialising, but would require custom serialisation. Is that your preference? |
Ugh serde does not make this easy does it? |
After a closer look it does seem like custom serialization might be the least-bad option here from a maintenance perspective. |
@lann Okay I have been exploring the custom serialisation (in a different branch, which I can share if it would help) and I am measurably dubious because it feels like either:
I don't trust myself or anybody else to do 1 correctly. So this approach seems to leave us with custom deserialisation and serde errors, which feels like brittle work for a worse UX. I am happy to press on with custom serialisation/deserialisation if you feel it's the right thing, but I wanted to touch base and make sure you still felt it was better than the wrapper type. |
I think deserialization can be handled with a serde enum; something like: // LockedApp {
must_understand: Vec<MustUnderstand>,
// }
#[derive(Deserialize)
#[serde(rename_all = "snake_case")]
enum MustUnderstand {
HostRequirements,
} It also could make sense to have a custom |
5cca3c8
to
69831ad
Compare
Okay this has mostly come together except for streaming. I have a test case where the front end streams its request to the back end, and streams the response from the back. When I route the front-to-back request, it works. When I chain the two, it deadlocks. I was SO CLOSE. |
Okay, I have two-way streaming working. I understand why my first attempt to test it deadlocked when chained, but I don't understand why it worked when routed - so I'm still concerned, because there is a behavioural difference, and that could trip folks up if they have a working streaming interaction and attempt to chain it. Still, unblocked for now I think. |
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'd be happy for someone with a better mental model of how wasi http works to review this (chain_request
in particular). @dicej?
@@ -347,7 +347,8 @@ impl HandlerType { | |||
|
|||
fn set_http_origin_from_request( | |||
store: &mut Store, | |||
engine: &TriggerAppEngine<HttpTrigger>, | |||
engine: &Arc<TriggerAppEngine<HttpTrigger>>, | |||
handler: &HttpHandlerExecutor, |
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 an empty struct. Any particular reason to pass it around?
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.
We could instantiate it within the function I guess, but conceptually what this is saying is "I want to use the exact same engine and executor that the HTTP trigger has set up." That the executor has no state today is an implementation detail that this function shouldn't have to care about.
Really I should probably Arc it rather than cloning it, in case changes are made to the executor after I capture it...
b2a6b4d
to
adb0a5d
Compare
adb0a5d
to
f7b288d
Compare
Signed-off-by: itowlson <[email protected]>
Signed-off-by: itowlson <[email protected]>
Signed-off-by: itowlson <[email protected]>
Signed-off-by: itowlson <[email protected]>
Signed-off-by: itowlson <[email protected]>
f7b288d
to
a5fa42c
Compare
@lann I'm still not happy with the LockedApp stuff. At the moment I check host requirements during deserialisation and that just doesn't work (because the
We've shied away from the first option, which leaves us with the second. (Or I'm missing something. Always plausible.) For triggers I can encapsulate the check in the trigger loader - which is probably the 90% case - but anything else will rely on the programmer knowing they need to do the check. Are we okay with that? Or did you already have another plan in mind for this? grin |
Signed-off-by: itowlson <[email protected]>
a5fa42c
to
4518b9a
Compare
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 mostly skimmed the loader bits (assuming Lann knows those best) and focused on the trigger-http
parts. Looks good to me, and it's actually simpler than I would have expected. Nice work!
Signed-off-by: itowlson <[email protected]>
Added a "check that the app doesn't need anything I don't provide" function and implemented it in the base trigger code. Example message: Note that because capabilities are checked at application level, this can misfire in mixed-trigger apps. A mixed app whose HTTP component allows cc @lann for opinioning |
(The alternative would be for the Redis trigger not to check, which would enable the "HTTP component chains but Redis does not" scenario, but would mean the "Redis component chains" scenario would sneak through and fail when the request was made. |
Extremely WIP and not ready for review! (This initial commit, for example, is just the core dispatch, none of the validation or precautions, and only minimally tested.)Tasks:
host_requirements
section and validationspin.toml
[N/A]Host: *.spin.internal
header from routed requests ✔️(TBD)[N/A]