Crate wasmcloud_actor_eventstreams

Source
Expand description

§Event Streams wasmCloud 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:

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())
}

Structs§

Event
A single event that occurred on a given stream
EventAck
Result object used for error handling and acknowledgement of events
EventList
Wrapper object around a list of events
Handlers
Host
StreamQuery
Used to query a stream for events with a maximum event count and optional time frame
TimeRange
Defines a range of time with a minimum and maximum timestamp (epoch time)
WriteEventArgs

Constants§

OP_QUERY_STREAM
OP_WRITE_EVENT

Functions§

default
Creates the default host binding
deserialize
The standard function for de-serializing codec structs from a format suitable for message exchange between actor and host. Use of any other function to deserialize could result in breaking incompatibilities.
host
Creates a named host binding
serialize
The standard function for serializing codec structs into a format that can be used for message exchange between actor and host. Use of any other function to serialize could result in breaking incompatibilities.