DenoDDeno
Powered by
nuclearwwcN
Denoβ€’7mo agoβ€’
14 replies
nuclearwwc

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
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?
Runtime in tokio::runtime - Rust
The Tokio runtime.
JsRuntime in deno_core - Rust
A single execution context of JavaScript. Corresponds roughly to the β€œWeb Worker” concept in the DOM.
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Is it possible to embed `deno_core` with a self-managed event loop?
linrongbin16Llinrongbin16 / help
2y ago
Call Rust function from Deno API
thomasmandorferTthomasmandorfer / help
2y ago
Deno event loop and gui application
ExidexEExidex / help
3y ago
deno in rust
webbdaysWwebbdays / help
2y ago