Overview
Add support for Fastly's Compute Runtime API, providing access to resource usage metrics and runtime environment information.
WIT Interface
interface compute-runtime {
type vcpu-ms = u64;
type memory-mib = u32;
get-vcpu-ms: func() -> vcpu-ms;
get-heap-mib: func() -> memory-mib;
get-sandbox-id: func() -> string;
get-hostname: func() -> string;
get-pop: func() -> string;
get-region: func() -> string;
get-cache-generation: func() -> u64;
get-customer-id: func() -> string;
get-is-staging: func() -> bool;
get-service-id: func() -> string;
get-service-version: func() -> u64;
get-namespace-id: func() -> string;
}
WIT bindings: stubs/wit_world/imports/compute_runtime.py
API Design
- Simple function-based module API
- Functions:
vcpu_ms(), heap_usage_mib(), sandbox_id(), hostname(), pop(), region(), etc.
- All functions are simple getters returning runtime information
- No resource management needed (stateless queries)
- Values equivalent to environment variables (
FASTLY_HOSTNAME, FASTLY_SERVICE_ID, etc.)
Cross-SDK Comparison: All SDKs provide getter functions for CPU/memory/time info. Rust returns structured types, Go returns primitives, JS returns objects. Python should provide simple module-level getters (get_cpu_time_ns()).
Viceroy Testing
Viceroy provides default/mock values for runtime information. Tests can verify:
- Function calls return expected types
- Sandbox ID is a valid UUID format
- Boolean flags work correctly
- Numeric values are reasonable
Actual runtime values will differ between Viceroy and production. Tests should focus on API functionality rather than specific values.
Reference
Overview
Add support for Fastly's Compute Runtime API, providing access to resource usage metrics and runtime environment information.
WIT Interface
WIT bindings:
stubs/wit_world/imports/compute_runtime.pyAPI Design
vcpu_ms(),heap_usage_mib(),sandbox_id(),hostname(),pop(),region(), etc.FASTLY_HOSTNAME,FASTLY_SERVICE_ID, etc.)Cross-SDK Comparison: All SDKs provide getter functions for CPU/memory/time info. Rust returns structured types, Go returns primitives, JS returns objects. Python should provide simple module-level getters (
get_cpu_time_ns()).Viceroy Testing
Viceroy provides default/mock values for runtime information. Tests can verify:
Actual runtime values will differ between Viceroy and production. Tests should focus on API functionality rather than specific values.
Reference