-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add Promise support for http callout #265
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: jizhuozhi.george <[email protected]>
fix ci Signed-off-by: jizhuozhi.george <[email protected]>
ci add `http_parallel_call` Signed-off-by: jizhuozhi.george <[email protected]>
|
fix ci Signed-off-by: jizhuozhi.george <[email protected]>
Thanks! I'll fix existing errors shortly. Sorry about that! |
move promise and dispatch http request to callout folder Signed-off-by: jizhuozhi.george <[email protected]>
remove Chinese comments Signed-off-by: jizhuozhi.george <[email protected]>
There is currently a problem involving the collaboration between SDK and user code: I have no idea to resolve this problem :( |
simplify http_parallel_call example Signed-off-by: jizhuozhi.george <[email protected]>
fix ci Signed-off-by: jizhuozhi.george <[email protected]>
fix example cloning self to move but not using hostcalls Signed-off-by: jizhuozhi.george <[email protected]>
fix licenses and bazel (maybe) Signed-off-by: jizhuozhi.george <[email protected]>
Bazel BUILD file has been reformatted :) |
Signed-off-by: jizhuozhi.george <[email protected]>
In the current envoy WASM plugins, if we need IO request such as HTTP/GRPC/Redis, we must register request to envoy event loop and assigned a token via such as
dispatch_http_call
and WASM plugin should yield current request lifetime usingAction::Pause
. When the IO request completed, the envoy will callback to WASM plugin viaon_http_call_response
, and plugin should dispatch response using token (or ignored if single IO request). If we want to share something betweendispatch_http_call
andon_http_call_response
, we must share them in plugin context fields, it's not a suitable scope.Here is an example from proxy-wasm-rust-sdk
So there is three major problem we need to resolve:
In Rust async programming, normally we use
async/await
for IO request, but in envoy WASM plugin, there is no executor to poll future. A suitable solution is providing JavaScript style Promise (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). With Promise, we could write all logic in single functionIt seems more fluid then writing in callback of
on_http_call_response
, but there is no executor for promise to trigger state transferring. We can useon_http_call_response
as trigger simplyAs for making relationship between multi tokens and promises, we could just using
HashMap
withinsert/remove
(maybe it should be embed in SDK but not belongs to this PR)Note:
hostcalls
is re-implemented ofresume_http_request
andsend_http_response
because we cannot moveself
to callbacks.