pub async fn execute(
        &self,
        entrypoint: &str,
        req: Request<Body>,
        client_addr: SocketAddr,
        cache_config_path: String,
        module_cache_dir: PathBuf,
    ) -> Response<Body> {
        // Read the parts in here
        log::trace!(
            "Module::execute: route={}, module={}",
            self.route,
            self.module
        );

        let (parts, body) = req.into_parts();
        let data = hyper::body::to_bytes(body)
            .await
            .unwrap_or_default()
            .to_vec();
        let ep = entrypoint.to_owned();
        let me = self.clone();
        let res = match tokio::task::spawn_blocking(move || {
            me.run_wasm(
                &ep,
                &parts,
                data,
                client_addr,
                cache_config_path,
                module_cache_dir,
            )
        })
        .await
        {
            Ok(res) => res,
            Err(e) if e.is_panic() => {
                log::error!("Recoverable panic on Wasm Runner thread: {}", e);
                return internal_error("Module run error");
            }
            Err(e) => {
                log::error!("Recoverable panic on Wasm Runner thread: {}", e);
                return internal_error("module run was cancelled");
            }
        };
        match res {
            Ok(res) => res,
            Err(e) => {
                log::error!("error running WASM module: {}", e);
                // A 500 error makes sense here
                let mut srv_err = Response::default();
                *srv_err.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
                srv_err
            }
        }
    }
/// Execute the WASM module in a WAGI
Execute the WASM module in a WAGI
Execute the WASM module in a WAGI
pub async fn execute(
        &self,
        entrypoint: &str,
        req: Request<Body>,
        client_addr: SocketAddr,
        cache_config_path: String,
        module_cache_dir: PathBuf,
    ) -> Response<Body> {
        // Read the parts in here
        log::trace!(
            "Module::execute: route={}, module={}",
            self.route,
            self.module
        );
        let (parts, body) = req.into_parts();
        let data = hyper::body::to_bytes(body)
            .await
            .unwrap_or_default()
            .to_vec();
        let ep = entrypoint.to_owned();
        let me = self.clone();
        let res = match tokio::task::spawn_blocking(move || {
            me.run_wasm(
                &ep,
                &parts,
                data,
                client_addr,
                cache_config_path,
                module_cache_dir,
            )
        })
        .await
        {
            Ok(res) => res,
            Err(e) if e.is_panic() => {
                log::error!("Recoverable panic on Wasm Runner thread: {}", e);
                return internal_error("Module run error");
            }
            Err(e) => {
                log::error!("Recoverable panic on Wasm Runner thread: {}", e);
                return internal_error("module run was cancelled");
            }
        };
        match res {
            Ok(res) => res,
            Err(e) => {
                log::error!("error running WASM module: {}", e);
                // A 500 error makes sense here
                let mut srv_err = Response::default();
                *srv_err.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
                srv_err
            }
        }
    }
pub async fn execute ( & self , entrypoint : & str , req : Request < Body > , client_addr : SocketAddr , cache_config_path : String , module_cache_dir : PathBuf , ) -> Response < Body > { // Read the parts in here log :: trace ! ( " " self route self module ) ; let ( parts , body ) = req . into_parts ( ) ; let data = hyper :: body :: to_bytes ( body ) . await . unwrap_or_default ( ) . to_vec ( ) ; let ep = entrypoint . to_owned ( ) ; let me = self . clone ( ) ; let res = match tokio :: task :: spawn_blocking ( move | | { me . run_wasm ( & ep , & parts , data , client_addr , cache_config_path , module_cache_dir , ) } ) . await { Ok ( res ) => res , Err ( e ) if e . is_panic ( ) => { log :: error ! ( " " e ) ; return internal_error ( " " ) ; } Err ( e ) => { log :: error ! ( " " e ) ; return internal_error ( " " ) ; } } ; match res { Ok ( res ) => res , Err ( e ) => { log :: error ! ( " " e ) ; // A 500 error makes sense here let mut srv_err = Response :: default ( ) ; * srv_err . status_mut ( ) = StatusCode :: INTERNAL_SERVER_ERROR ; srv_err } } }
Execute the WASM module in a WAGI
Execute the WASM module in a WAGI
&self
entrypoint
&str
req
Request<Body>
client_addr
SocketAddr
cache_config_path
String
module_cache_dir
PathBuf