diff --git a/crates/adapter/src/fastly/core.rs b/crates/adapter/src/fastly/core.rs index 46027a0a..15d0df7e 100644 --- a/crates/adapter/src/fastly/core.rs +++ b/crates/adapter/src/fastly/core.rs @@ -268,12 +268,12 @@ pub mod fastly_abi { } } -pub mod fastly_vcpu { +pub mod fastly_compute_runtime { use super::*; - #[export_name = "fastly_vcpu#get_vcpu_ms"] + #[export_name = "fastly_compute_runtime#get_vcpu_ms"] pub fn get_vcpu_ms(vcpu_time_ms_out: *mut u64) -> FastlyStatus { - match crate::bindings::fastly::api::vcpu::get_vcpu_ms() { + match crate::bindings::fastly::api::compute_runtime::get_vcpu_ms() { Ok(time) => { unsafe { *vcpu_time_ms_out = time; diff --git a/lib/compute-at-edge-abi/compute-at-edge.witx b/lib/compute-at-edge-abi/compute-at-edge.witx index cb559951..de18f80f 100644 --- a/lib/compute-at-edge-abi/compute-at-edge.witx +++ b/lib/compute-at-edge-abi/compute-at-edge.witx @@ -966,7 +966,7 @@ ) ) -(module $fastly_vcpu +(module $fastly_compute_runtime (@interface func (export "get_vcpu_ms") (result $err (expected $vcpu_ms (error $fastly_status))) ) diff --git a/lib/data/viceroy-component-adapter.wasm b/lib/data/viceroy-component-adapter.wasm index 7a851594..303c4243 100755 Binary files a/lib/data/viceroy-component-adapter.wasm and b/lib/data/viceroy-component-adapter.wasm differ diff --git a/lib/src/component/vcpu.rs b/lib/src/component/compute_runtime.rs similarity index 71% rename from lib/src/component/vcpu.rs rename to lib/src/component/compute_runtime.rs index 78668bec..9c4bf962 100644 --- a/lib/src/component/vcpu.rs +++ b/lib/src/component/compute_runtime.rs @@ -1,9 +1,9 @@ -use super::fastly::api::{types, vcpu}; +use super::fastly::api::{types, compute_runtime}; use crate::session::Session; use std::sync::atomic::Ordering; #[async_trait::async_trait] -impl vcpu::Host for Session { +impl compute_runtime::Host for Session { async fn get_vcpu_ms(&mut self) -> Result { Ok(self.active_cpu_time_us.load(Ordering::SeqCst) / 1000) } diff --git a/lib/src/component/mod.rs b/lib/src/component/mod.rs index 947ee7c0..c667056c 100644 --- a/lib/src/component/mod.rs +++ b/lib/src/component/mod.rs @@ -59,7 +59,7 @@ pub fn link_host_functions(linker: &mut component::Linker) -> anyh fastly::api::types::add_to_linker(linker, |x| x.session())?; fastly::api::uap::add_to_linker(linker, |x| x.session())?; fastly::api::config_store::add_to_linker(linker, |x| x.session())?; - fastly::api::vcpu::add_to_linker(linker, |x| x.session())?; + fastly::api::compute_runtime::add_to_linker(linker, |x| x.session())?; Ok(()) } @@ -67,6 +67,7 @@ pub fn link_host_functions(linker: &mut component::Linker) -> anyh pub mod async_io; pub mod backend; pub mod cache; +pub mod compute_runtime; pub mod config_store; pub mod device_detection; pub mod dictionary; @@ -84,4 +85,3 @@ pub mod purge; pub mod secret_store; pub mod types; pub mod uap; -pub mod vcpu; diff --git a/lib/src/linking.rs b/lib/src/linking.rs index 8e6f46b1..e81bed4d 100644 --- a/lib/src/linking.rs +++ b/lib/src/linking.rs @@ -303,7 +303,7 @@ pub fn link_host_functions( wiggle_abi::fastly_uap::add_to_linker(linker, WasmCtx::session)?; wiggle_abi::fastly_async_io::add_to_linker(linker, WasmCtx::session)?; wiggle_abi::fastly_backend::add_to_linker(linker, WasmCtx::session)?; - wiggle_abi::fastly_vcpu::add_to_linker(linker, WasmCtx::session)?; + wiggle_abi::fastly_compute_runtime::add_to_linker(linker, WasmCtx::session)?; link_legacy_aliases(linker)?; Ok(()) } diff --git a/lib/src/wiggle_abi.rs b/lib/src/wiggle_abi.rs index 1e6e33ec..bd76b3b0 100644 --- a/lib/src/wiggle_abi.rs +++ b/lib/src/wiggle_abi.rs @@ -51,6 +51,7 @@ macro_rules! multi_value_result { mod backend_impl; mod body_impl; mod cache; +mod compute_runtime; mod config_store; mod device_detection_impl; mod dictionary_impl; @@ -65,7 +66,6 @@ mod req_impl; mod resp_impl; mod secret_store_impl; mod uap_impl; -mod vcpu; // Expand the `.witx` interface definition into a collection of modules. The `types` module will // contain all of the `typename`'s defined in the `witx` file, and other modules will export traits diff --git a/lib/src/wiggle_abi/vcpu.rs b/lib/src/wiggle_abi/compute_runtime.rs similarity index 81% rename from lib/src/wiggle_abi/vcpu.rs rename to lib/src/wiggle_abi/compute_runtime.rs index 4ee8aacc..b672aaca 100644 --- a/lib/src/wiggle_abi/vcpu.rs +++ b/lib/src/wiggle_abi/compute_runtime.rs @@ -1,10 +1,10 @@ use crate::error::Error; use crate::session::Session; -use crate::wiggle_abi::fastly_vcpu::FastlyVcpu; +use crate::wiggle_abi::fastly_compute_runtime::FastlyComputeRuntime; use std::sync::atomic::Ordering; use wiggle::GuestMemory; -impl FastlyVcpu for Session { +impl FastlyComputeRuntime for Session { fn get_vcpu_ms(&mut self, _memory: &mut GuestMemory<'_>) -> Result { // we internally track microseconds, because our wasmtime tick length // is too short for ms to work. but we want to shrink this to ms to diff --git a/lib/wit/deps/fastly/compute.wit b/lib/wit/deps/fastly/compute.wit index d6d4da7e..bf76171d 100644 --- a/lib/wit/deps/fastly/compute.wit +++ b/lib/wit/deps/fastly/compute.wit @@ -1086,7 +1086,7 @@ interface reactor { serve: func(req: request-handle, body: body-handle) -> result; } -interface vcpu { +interface compute-runtime { use types.{error}; type vcpu-ms = u64; @@ -1109,6 +1109,7 @@ world compute { import async-io; import backend; import cache; + import compute-runtime; import dictionary; import geo; import device-detection; @@ -1122,7 +1123,6 @@ world compute { import secret-store; import config-store; import uap; - import vcpu; export reactor; } diff --git a/test-fixtures/src/bin/vcpu_time_test.rs b/test-fixtures/src/bin/vcpu_time_test.rs index d3bb4896..65401691 100644 --- a/test-fixtures/src/bin/vcpu_time_test.rs +++ b/test-fixtures/src/bin/vcpu_time_test.rs @@ -5,7 +5,7 @@ use hex_literal::hex; use sha2::{Sha512, Digest}; use std::time::{Duration, Instant}; -#[link(wasm_import_module = "fastly_vcpu")] +#[link(wasm_import_module = "fastly_compute_runtime")] extern "C" { #[link_name = "get_vcpu_ms"] pub fn get_vcpu_ms(ms_out: *mut u64) -> FastlyStatus;