pub struct StreamManager { /* private fields */ }Expand description
Stream Manager interface
Uses StreamableHTTP protocol for all operations.
Event Streams are reactive by default - use observe_events() or observe_event().
Implementations§
Source§impl StreamManager
impl StreamManager
Sourcepub async fn create_room(
&self,
room: &str,
max_events: Option<usize>,
) -> Result<()>
pub async fn create_room( &self, room: &str, max_events: Option<usize>, ) -> Result<()>
Create a new stream room
Sourcepub async fn consume(
&self,
room: &str,
offset: Option<u64>,
limit: Option<usize>,
) -> Result<Vec<Event>>
pub async fn consume( &self, room: &str, offset: Option<u64>, limit: Option<usize>, ) -> Result<Vec<Event>>
Consume events from a stream
§Arguments
room- Stream room nameoffset- Starting offset (None = from beginning)limit- Maximum events to fetch
Sourcepub async fn stats(&self, room: &str) -> Result<StreamStats>
pub async fn stats(&self, room: &str) -> Result<StreamStats>
Get stream statistics
Sourcepub async fn delete_room(&self, room: &str) -> Result<()>
pub async fn delete_room(&self, room: &str) -> Result<()>
Delete a stream room
Source§impl StreamManager
impl StreamManager
Sourcepub fn observe_events(
&self,
room: impl Into<String>,
start_offset: Option<u64>,
poll_interval: Duration,
) -> (impl Stream<Item = Event> + 'static, SubscriptionHandle)
pub fn observe_events( &self, room: impl Into<String>, start_offset: Option<u64>, poll_interval: Duration, ) -> (impl Stream<Item = Event> + 'static, SubscriptionHandle)
Observe events from a stream room reactively
Returns a Stream of events that can be processed asynchronously. The stream will poll for new events at the specified interval.
§Example
use futures::StreamExt;
use synap_sdk::{SynapClient, SynapConfig};
use std::time::Duration;
let (mut stream, handle) = client.stream()
.observe_events("chat-room-1", Some(0), Duration::from_millis(100));
// Process events reactively
while let Some(event) = stream.next().await {
println!("Event {}: {:?}", event.offset, event.data);
}
// Stop observing
handle.unsubscribe();Sourcepub fn observe_event(
&self,
room: impl Into<String>,
event_type: impl Into<String>,
start_offset: Option<u64>,
poll_interval: Duration,
) -> (impl Stream<Item = Event> + 'static, SubscriptionHandle)
pub fn observe_event( &self, room: impl Into<String>, event_type: impl Into<String>, start_offset: Option<u64>, poll_interval: Duration, ) -> (impl Stream<Item = Event> + 'static, SubscriptionHandle)
Observe specific event types from a stream
Filters events by event type before delivering them.
Trait Implementations§
Source§impl Clone for StreamManager
impl Clone for StreamManager
Source§fn clone(&self) -> StreamManager
fn clone(&self) -> StreamManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StreamManager
impl !RefUnwindSafe for StreamManager
impl Send for StreamManager
impl Sync for StreamManager
impl Unpin for StreamManager
impl !UnwindSafe for StreamManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more