#webassembly #wasm #wasmcloud #actor

wasmcloud-actor-messaging

Messaging wasmCloud Actor Interface

3 releases

0.1.2 Apr 16, 2021
0.1.1 Feb 17, 2021
0.1.0 Feb 10, 2021

#22 in #wasmcloud

Download history 15/week @ 2021-02-25 22/week @ 2021-03-04 11/week @ 2021-03-11 10/week @ 2021-03-18 11/week @ 2021-03-25 3/week @ 2021-04-01 4/week @ 2021-04-08 28/week @ 2021-04-15 10/week @ 2021-04-22 6/week @ 2021-04-29 2/week @ 2021-05-06 20/week @ 2021-05-13 2/week @ 2021-05-20 3/week @ 2021-05-27 6/week @ 2021-06-03 8/week @ 2021-06-10

51 downloads per month
Used in wasmcloud-nats

Apache-2.0

10KB
156 lines

crates.io  Rust license  documentation

wasmCloud Messaging Actor Interface

This crate provides wasmCloud actors with an interface to the Messaging capability provider. Actors using this interface must have the claim wasmcloud:messaging in order to have permission to handle messages, publish and perform request-response actions. They also must have an active, configured binding to a Messaging capability provider.

Example:

extern crate wasmcloud_actor_messaging as messaging;
extern crate wasmcloud_actor_core as actor;
extern crate wapc_guest as guest;
use guest::prelude::*;

#[actor::init]
pub fn init() {
    messaging::Handlers::register_handle_message(handle_message);
}

/// Reply to a "ping" message with "pong"
fn handle_message(message: messaging::BrokerMessage) -> HandlerResult<()> {
    if String::from_utf8(message.body)? == "ping".to_string() {
        messaging::default().publish(message.reply_to, "".to_string(), "pong".to_string().into_bytes())?;
    }
    Ok(())
}

Dependencies

~1–1.7MB
~37K SLoC