Crate bonsaidb::core::circulate

Expand description

crate version Live Build Status Documentation for main branch

Circulate is a lightweight PubSub framework that supports both async and non-async code. This project is written for BonsaiDb. While BonsaiDb’s async relies upon tokio, this crate is runtime agnostic thanks to the excellent crate flume.

Async Example

let relay = Relay::default();
let subscriber = relay.create_subscriber();

subscriber.subscribe_to(&"some topic")?;

relay.publish(&"some topic", &AnySerializableType)?;

let message = subscriber.receiver().recv_async().await?;
println!(
    "Received message on topic {}: {:?}",
    message.topic::<String>()?, 
    message.payload::<AnySerializableType>()?
);

Sync Example

let relay = Relay::default();
let subscriber = relay.create_subscriber();

subscriber.subscribe_to(&"some topic")?;

relay.publish(&"some topic", &AnySerializableType)?;

let message = subscriber.receiver().recv()?;
println!(
    "Received message on topic {}: {:?}",
    message.topic::<String>()?, 
    message.payload::<AnySerializableType>()?
);

Modules

Structs

  • A PubSub message.
  • Manages subscriptions and notifications for PubSub.
  • A subscriber for Messages published to subscribed topics.