#webassembly #wasm #wasmcloud #actor

wasmcloud-actor-keyvalue

Interface to the key-value contract for use by wasmCloud Actors

3 releases

0.2.2 Apr 16, 2021
0.2.1 Feb 17, 2021
0.2.0 Feb 10, 2021

#437 in WebAssembly

Download history 27/week @ 2021-05-25 38/week @ 2021-06-01 39/week @ 2021-06-08 31/week @ 2021-06-15 24/week @ 2021-06-22 40/week @ 2021-06-29 14/week @ 2021-07-06 25/week @ 2021-07-13 41/week @ 2021-07-20 53/week @ 2021-07-27 44/week @ 2021-08-03 39/week @ 2021-08-10 11/week @ 2021-08-17 35/week @ 2021-08-24 9/week @ 2021-08-31 13/week @ 2021-09-07

504 downloads per month
Used in 6 crates (4 directly)

Apache-2.0

18KB
398 lines

crates.io  Rust license  documentation

wasmCloud Key Value Store Actor Interface

This crate provides an interface for actors to use to communicate with a key-value store capability provider. Actors using this interface must have the wasmcloud:keyvalue capability permission.

This crate is one-way, and only supports actors making calls to the host. The capability provider does not deliver messages to actors (e.g. actors cannot subscribe to store change events).

The following is an example usage:

#[macro_use]
extern crate serde_json;
extern crate wasmcloud_actor_http_server as http;
extern crate wasmcloud_actor_keyvalue as kv;
extern crate wasmcloud_actor_core as actor;

use http::{self, Request, Response};
use wascap_guest::HandlerResult;

#[macro_use]
extern crate serde_json;

#[actor::init]
pub fn init() {
    http::Handlers::register_handle_request(increment_counter);
}

fn increment_counter(msg: Request) -> HandlerResult<Response> {
    let key = msg.path.replace('/', ":");
    let resp = kv::default().add(key.to_string(), 1)?;

    let result = json!({"counter": resp.value });
    Ok(Response::json(result, 200, "OK")?)
}

Dependencies

~1.3–2.2MB
~48K SLoC