#wasm #wasmcloud #actor #events

wasmcloud-actor-blobstore

Interface to the blobstore contract for use by wasmCloud Actors

5 releases

0.2.2 May 17, 2021
0.2.1 Apr 16, 2021
0.2.0 Mar 18, 2021
0.1.1 Feb 16, 2021
0.1.0 Feb 10, 2021

#382 in WebAssembly

Download history 6/week @ 2021-02-25 6/week @ 2021-03-04 20/week @ 2021-03-11 62/week @ 2021-03-18 16/week @ 2021-03-25 49/week @ 2021-04-01 38/week @ 2021-04-08 29/week @ 2021-04-15 16/week @ 2021-04-22 8/week @ 2021-04-29 1/week @ 2021-05-06 52/week @ 2021-05-13 6/week @ 2021-05-20 3/week @ 2021-05-27 9/week @ 2021-06-03 8/week @ 2021-06-10

89 downloads per month
Used in 2 crates

Apache-2.0

20KB
330 lines

crates.io Rust license documentation

wasmCloud Blob Store Actor Interface

This crate provides wasmCloud actors with an interface to the blobstore capability provider. Actors using this interface must have the claim wasmcloud:blobstore in order to have permission to communicate with the store.

This generic protocol can be used to support capability providers like local blob storage, Amazon S3, Azure blob storage, Google blob storage, and more.

Example

use wapc_guest as guest;
use guest::prelude::*;
use wasmcloud_actor_blobstore as blobstore;
use wasmcloud_actor_http_server as http;
use wasmcloud_actor_core as actor;
use actor::{serialize, init};
use blobstore::*;
use serde_json::json;
use log::{error, info};

#[actor::init]
fn init() {
    http::Handlers::register_handle_request(download_poem);
    blobstore::Handlers::register_receive_chunk(handle_chunk);   
}

fn download_poem(req: http::Request) -> HandlerResult<http::Response> {    
    match blobstore::default().start_download(req.path, "poems".to_string(), 4096, None) {
        Ok(_) => Ok(http::Response::ok()),
        Err(_) => Err("Failed to initiate download of chunk".into())
    }
}

 /// Handle the incoming chunk as a poem "verse" and log the result
 /// Note that these chunks can be received out of order, so the poem
 /// in this case might be displayed in a different order and could look
 /// funny if the verse continues across a chunk boundary
 fn handle_chunk(chunk: FileChunk) -> HandlerResult<()> {
     let verse = String::from_utf8(chunk.chunk_bytes)?;
     info!("Poem {} part {}:\n{}", chunk.id, chunk.sequence_no, verse);
     Ok(())
 }


Dependencies

~1.3–2.1MB
~47K SLoC