Skip to content

WASM Edge Computing: API Reference

WASM Edge Computing: API Reference

Part of: WASM Edge Computing User Guide


EdgeRuntimeManager

impl EdgeRuntimeManager {
/// Create new runtime manager with configuration
pub fn new(config: EdgeRuntimeConfig) -> Self;
/// Create with default configuration
pub fn with_defaults() -> Self;
/// Start the runtime manager
pub async fn start(&mut self) -> Result<()>;
/// Stop the runtime manager
pub async fn stop(&mut self) -> Result<()>;
/// Register an edge node
pub async fn register_node(&self, node: EdgeNode) -> Result<()>;
/// Unregister an edge node
pub async fn unregister_node(&self, node_id: &str) -> Result<()>;
/// Deploy function to all regions
pub async fn deploy_globally(&self, function_name: String) -> Result<Vec<Region>>;
/// Route request to optimal edge node
pub async fn route_request(
&self,
client_location: Option<(f64, f64)>,
session_id: Option<String>,
) -> Result<RoutingDecision>;
/// Get runtime statistics
pub async fn get_stats(&self) -> EdgeRuntimeStats;
/// Get all nodes
pub async fn get_nodes(&self) -> Vec<EdgeNode>;
/// Get nodes by region
pub async fn get_nodes_by_region(&self, region: Region) -> Vec<EdgeNode>;
}

GeoRouter

impl GeoRouter {
/// Create router with strategy
pub fn new(strategy: RoutingStrategy) -> Self;
/// Register an edge node
pub fn register_node(&self, node: EdgeNodeInfo);
/// Unregister an edge node
pub fn unregister_node(&self, node_id: &str);
/// Update node status
pub fn update_node_status(&self, node_id: &str, update: NodeStatusUpdate);
/// Route to optimal edge node
pub fn route(&self, client_location: GeoLocation) -> Result<RoutingDecision>;
/// Get routing statistics
pub fn stats(&self) -> RoutingStats;
/// Get all registered nodes
pub fn get_nodes(&self) -> Vec<EdgeNodeInfo>;
/// Remove stale nodes
pub fn cleanup_stale_nodes(&self, max_age_secs: i64);
}

CdnIntegrationManager

impl CdnIntegrationManager {
/// Create new CDN integration manager
pub fn new() -> Self;
/// Register a CDN provider
pub async fn register_provider(&self, config: CdnConfig) -> Result<()>;
/// Deploy function to CDN provider
pub async fn deploy(
&self,
provider: CdnProvider,
function_name: String,
wasm_bytes: Vec<u8>,
version: String,
) -> Result<String>;
/// Deploy to all configured providers
pub async fn deploy_all(
&self,
function_name: String,
wasm_bytes: Vec<u8>,
version: String,
) -> Result<HashMap<CdnProvider, String>>;
/// Purge cache for provider
pub async fn purge_cache(&self, provider: CdnProvider, keys: Vec<String>) -> Result<()>;
/// Warm cache with specific keys
pub async fn warm_cache(&self, provider: CdnProvider, keys: Vec<String>) -> Result<()>;
/// Invalidate cache by pattern
pub async fn invalidate_pattern(&self, provider: CdnProvider, pattern: String) -> Result<()>;
/// Add geo-fencing rule
pub async fn add_geo_fence(&self, rule: GeoFenceRule) -> Result<()>;
/// Set rate limit for provider
pub async fn set_rate_limit(&self, provider: CdnProvider, config: RateLimitConfig) -> Result<()>;
/// Get cache statistics
pub async fn get_cache_stats(&self, provider: CdnProvider) -> Option<CacheStats>;
/// Get all deployments
pub async fn get_deployments(&self) -> Vec<CdnDeployment>;
/// Retire a deployment
pub async fn retire_deployment(&self, deployment_id: &str) -> Result<()>;
}

EdgeStateSynchronizer

impl EdgeStateSynchronizer {
/// Create new state synchronizer
pub fn new(node_id: String, config: SyncConfig) -> Self;
/// Create with defaults
pub fn with_defaults(node_id: String) -> Self;
/// Start synchronizer
pub async fn start(&mut self) -> Result<()>;
/// Stop synchronizer
pub async fn stop(&mut self) -> Result<()>;
/// Put value (write-global)
pub async fn put(&self, key: String, value: Vec<u8>, ttl: Option<Duration>) -> Result<()>;
/// Get value (read-local)
pub async fn get(&self, key: &str) -> Result<Option<Vec<u8>>>;
/// Delete value
pub async fn delete(&self, key: &str) -> Result<()>;
/// Subscribe to partition
pub async fn subscribe_partition(&self, partition_id: &str) -> Result<()>;
/// Unsubscribe from partition
pub async fn unsubscribe_partition(&self, partition_id: &str) -> Result<()>;
/// Synchronize with another node
pub async fn sync_with_node(&self, target_node_id: &str) -> Result<()>;
/// Apply sync delta
pub async fn apply_delta(&self, delta: SyncDelta) -> Result<()>;
/// Get statistics
pub async fn get_stats(&self) -> SyncStats;
/// Get partition count
pub async fn partition_count(&self) -> usize;
/// Get total entry count
pub async fn entry_count(&self) -> usize;
/// List keys in partition
pub async fn list_keys(&self, partition_id: &str) -> Vec<String>;
}

MultiTierCache

impl<K, V> MultiTierCache<K, V>
where
K: Clone + Eq + Hash + Serialize + for<'de> Deserialize<'de>,
V: Clone + Serialize + for<'de> Deserialize<'de>,
{
/// Create new multi-tier cache
pub async fn new(config: MultiTierCacheConfig) -> Result<Self>;
/// Get value (checks all tiers)
pub async fn get(&self, key: &K) -> Result<Option<V>>;
/// Insert value (starts at L2)
pub async fn insert(&self, key: K, value: V, size_bytes: u64, ttl_secs: Option<u64>) -> Result<()>;
/// Remove from all tiers
pub async fn remove(&self, key: &K) -> Result<bool>;
/// Get statistics
pub fn stats(&self) -> MultiTierCacheStats;
/// Get prefetch predictions
pub fn get_prefetch_predictions(&self, window_secs: u64) -> Vec<u64>;
/// Record prefetch hit
pub fn record_prefetch_hit(&self);
/// Record prefetch miss
pub fn record_prefetch_miss(&self);
/// Demote cold entries from L1 to L2
pub async fn demote_cold_entries(&self) -> Result<usize>;
/// Get hot keys by frequency
pub fn get_hot_keys(&self, top_n: usize) -> Vec<u64>;
}