#wasm #wasmcloud #actor #events

wasmcloud-actor-eventstreams

Interface to the event streams contract for use by wasmCloud Actors

4 releases

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

#21 in #events

Download history 3/week @ 2021-02-20 8/week @ 2021-02-27 56/week @ 2021-03-06 20/week @ 2021-03-13 8/week @ 2021-03-20 7/week @ 2021-03-27 7/week @ 2021-04-03 17/week @ 2021-04-10 25/week @ 2021-04-17 3/week @ 2021-04-24 6/week @ 2021-05-01 2/week @ 2021-05-08 23/week @ 2021-05-15 1/week @ 2021-05-22 5/week @ 2021-05-29 7/week @ 2021-06-05

61 downloads per month
Used in wasmcloud-streams-redis

Apache-2.0

10KB
152 lines

crates.io Rust license documentation

wasmCloud Event Streams Actor Interface

This crate provides an abstraction over the wasmcloud:eventstreams contract. This allows actors to write immutable events to a stream, receive events from a stream, and query events from a stream.

Example

#[macro_use]
extern crate wasmcloud_actor_core as actor;
extern crate wasmcloud_actor_eventstreams as streams;
extern crate wasmcloud_actor_http_server as http;

use wapc_guest::HandlerResult;
use streams::*;
use std::collections::HashMap;

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

fn handle_request(_req: http::Request) -> HandlerResult<http::Response> {
   // process event, query streams, or send new events...
   let _evts_so_far = streams::default()
      .query_stream(StreamQuery{
          stream_id: "hello_stream".to_string(),
          range: None,
          count: 0                   
   });
   let ack = streams::default().write_event("hello_stream".to_string(),
         HashMap::new())?;
   Ok(http::Response::ok())
}

Dependencies

~1.3–2.1MB
~47K SLoC