nuclearwwc
nuclearwwc6d ago

Embed Deno into Rust App: How to call other method with poll_event_loop keep going

Hi, all, I'm trying embed deno_core into Rust Gateway. like openresty(lua) in NGINX but for Deno(javascript) After reading the docs, I need continuously call https://docs.rs/deno_core/latest/deno_core/struct.JsRuntime.html#method.run_event_loop to make deno event loop running. Sometime, after gateway received request headers, we need to call method on_recv_request_header in Deno script, but due to the call to run_event_loop, we already await blocked in there, I can't get JsRuntime back, So I need find a way to stop run_event_loop temporarily, get JsRuntime back , then call run_event_loop again Possible solution: It there have a method so I can get JsRuntime handle(like https://docs.rs/tokio/latest/tokio/runtime/struct.Runtime.html#method.handle), move the run_event_loop to another async task, then call other method in current task?
JsRuntime in deno_core - Rust
A single execution context of JavaScript. Corresponds roughly to the “Web Worker” concept in the DOM.
1 Reply
Filou
Filou5d ago
Deno
Roll your own JavaScript runtime | Deno
A walk-through of creating a CLI that executes JavaScript files.

Did you find this page helpful?