JMLX42 commented on PR #7156:
URL: https://github.com/apache/opendal/pull/7156#issuecomment-3812243548

   I have been making great progress thanks to this little PR.
   
   ## Services already available as WASM components
   
   Two services have already been transformed into WASM components:
   
   1. `opendal-fs.wasm` is a WASM/WASI compliant re-implementation of OpenDAL's 
`Fs` service (which can't be used directly because it depends on `tokio`)
   2. `opendal-memory.wasm` is a WASM component that directly uses OpenDAL's 
vanilla `Memory` service. Proving that existing OpenDAL services can just be 
compiled to a WASM component without a single modification.
   
   So OpenDAL WASM component can now be created with just a few lines of code:
   
   ```rust
   use std::sync::OnceLock;
   
   use opendal::services::MemoryConfig;
   use opendal::Operator;
   use opendal_wit::OperatorBackend;
   
   static OPERATOR: OnceLock<Result<Operator, opendal::Error>> = 
OnceLock::new();
   
   struct MemoryComponent;
   
   impl OperatorBackend for MemoryComponent {
       type Config = MemoryConfig;
   
       fn operator_cell() -> &'static OnceLock<Result<Operator, 
opendal::Error>> {
           &OPERATOR
       }
   }
   
   opendal_wit::export!(MemoryComponent with_types_in opendal_wit);
   ```
   
   All the components:
   
   - export a common WIT interface defined 
[here](https://gitlab.com/lx-industries/opendal-wasi/-/blob/2f9643e34ff5b1e6c73762f443578aa5c4df094c/wit/opendal.wit)
   - are stored/distributed as OCI artifacts 
[here](https://gitlab.com/lx-industries/opendal-wasi/container_registry)
   
   This has the potential to bring OpenDAL to *any* platform that supports WASM 
without any specific work on the original Rust code base.
   
   ## Next steps for `opendal-wasi`
   
   The next step is to test an HTTP driven service such as `S3`. I already have 
implemented `HttpFetch` for WASI 
[here](https://gitlab.com/lx-industries/opendal-wasi/-/blob/2f9643e34ff5b1e6c73762f443578aa5c4df094c/crates/opendal-wasi/src/raw/http.rs).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to