wasmCloud / interfaces

Deprecated: wasmCloud API interfaces: smithy IDLs and shared libraries
https://wasmcloud.github.io/interfaces/
Apache License 2.0
34 stars 22 forks source link

Blobstore `Chunk`s do not support borrowed data in Rust #103

Closed thomastaylor312 closed 1 year ago

thomastaylor312 commented 1 year ago

This is a Rust only request

Right now the put_object and put_chunk functions use the Chunk object. This object requires the bytes to be an owned Vec<u8>. Because the data on incoming requests (like from an HttpRequest from wasmcloud:httpserver) isn't owned, this means that the data has to be cloned to send to the blobstore. So if someone sends a 20 MB file (just as an example), we then have to allocate another 20MB of memory in order to send things.

There are two possible solutions (both of which should be implemented IMO)

  1. This is the easier one. Make the blobstore contract support borrowed data for Chunk. This should probably be done either way
  2. This is the harder one: Most interfaces should accept owned rather than borrowed data. So for example, the httpserver contract should change from
async fn handle_request(&self, ctx: &Context, req: &HttpRequest) -> RpcResult<HttpResponse>

to

async fn handle_request(&self, ctx: &Context, req: HttpRequest) -> RpcResult<HttpResponse>

NOTE: This could be more of a https://github.com/wasmCloud/weld issue in the end as it deals with generated interface code, but I thought it would be good to start here

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this has been closed too eagerly, please feel free to tag a maintainer so we can keep working on the issue. Thank you for contributing to wasmCloud!