wasmcloud-actor-eventstreams

Crates.iowasmcloud-actor-eventstreams
lib.rswasmcloud-actor-eventstreams
version0.2.1
sourcesrc
created_at2021-02-10 15:58:03.849533
updated_at2021-04-16 15:54:08.511995
descriptionInterface to the event streams contract for use by wasmCloud Actors
homepage
repository
max_upload_size
id353263
size11,305
wasmCloud Automation Bot (wasmcloud-automation)

documentation

https://docs.rs/wasmcloud-actor-eventstreams

README

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())
}
Commit count: 0

cargo fmt