The Wayback Machine - https://web.archive.org/web/20230128065019/https://github.com/WasmEdge/wasmedge-anna-client
Skip to content

WasmEdge/wasmedge-anna-client

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

anna-rs client for WebAssembly

wasmedge-anna-client is a Rust client for anna-rs based on Tokio for WasmEdge. It communicates with anna-rs routing nodes and KVS nodes via vanilla TCP connections instead of Zenoh.

The wasmedge-anna-client can be compiled into WebAssembly. The WebAssembly app can run inside the WasmEdge Runtime as a lightweight and secure alternative to natively compiled apps in Linux container.

Usage

use std::time::Duration;
use wasmedge_anna_client::{Client, ClientConfig};

let mut client = Client::new(ClientConfig {
    routing_ip: "127.0.0.1".parse().unwrap(),
    routing_port_base: 12340,
    routing_threads: 1,
    timeout: Duration::from_secs(10),
})?;

// put the value
client.put_lww("foo".into(), "bar".into()).await?;

// sleep 1 second
tokio::time::sleep(Duration::from_secs(1)).await;

// get the value
let bytes = client.get_lww("foo".into()).await?;
let value = String::from_utf8(bytes)?;
println!("Successfully GET value of `foo`: {}", value);

Run the example

First, run routing node and KVS node of anna-rs:

$ cd anna-rs
$ cp example-config.yml config.yml
$ ANNA_PUBLIC_IP=127.0.0.1 ANNA_TCP_PORT_BASE=12340 cargo run --bin routing -- config.yml
$ # in another shell
$ ANNA_PUBLIC_IP=127.0.0.1 cargo run --bin kvs -- config.yml

Then, build and run the example app of wasmedge-anna-client:

$ cd example
$ cargo build --target wasm32-wasi
$ /path/to/wasmedge --dir .:. target/wasm32-wasi/debug/example.wasm

You can find more examples in wasmedge-db-examples.

Attribution

Many code of this driver is derived from anna-rs.

About

Rust client for the anna-rs KVS that can run in the WasmEdge Runtime

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages