mirror of
https://github.com/marcoallegretti/WEFT_OS.git
synced 2026-03-26 17:03:09 +00:00
feat(runtime): add weft:app/notify WIT package and notify-ready host interface
Adds crates/weft-runtime/wit/weft-app.wit defining package weft:app@0.1.0
with interface notify { ready: func() }.
In the wasmtime-runtime path:
- Registers weft:app/notify@0.1.0 in the component linker before instantiation
- ready() prints
This commit is contained in:
parent
b2ac279dc5
commit
84eb39db96
2 changed files with 18 additions and 2 deletions
|
|
@ -127,6 +127,14 @@ fn run_module(
|
|||
|
||||
let mut linker: Linker<State> = Linker::new(&engine);
|
||||
add_to_linker_sync(&mut linker).context("add WASI to linker")?;
|
||||
linker
|
||||
.instance("weft:app/notify@0.1.0")
|
||||
.context("define weft:app/notify instance")?
|
||||
.func_wrap("ready", |_: wasmtime::StoreContextMut<'_, State>, ()| {
|
||||
println!("READY");
|
||||
Ok::<(), wasmtime::Error>(())
|
||||
})
|
||||
.context("define weft:app/notify#ready")?;
|
||||
|
||||
let mut ctx_builder = WasiCtxBuilder::new();
|
||||
ctx_builder.inherit_stdout().inherit_stderr();
|
||||
|
|
@ -150,8 +158,6 @@ fn run_module(
|
|||
},
|
||||
);
|
||||
|
||||
println!("READY");
|
||||
|
||||
let command =
|
||||
Command::instantiate(&mut store, &component, &linker).context("instantiate component")?;
|
||||
|
||||
|
|
|
|||
10
crates/weft-runtime/wit/weft-app.wit
Normal file
10
crates/weft-runtime/wit/weft-app.wit
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package weft:app@0.1.0;
|
||||
|
||||
/// Host interface that a WEFT app component imports to signal lifecycle events.
|
||||
interface notify {
|
||||
/// Signal to the runtime that the application has finished initialising
|
||||
/// and is ready to serve requests. The runtime forwards this signal to
|
||||
/// the session supervisor (appd), which transitions the session to the
|
||||
/// Running state.
|
||||
ready: func();
|
||||
}
|
||||
Loading…
Reference in a new issue