#bonsaidb #publish-subscribe #framework #tokio #pubsub #async

circulate

Lightweight PubSub framework that supports both sync and async

7 releases (4 breaking)

0.5.0 Aug 24, 2023
0.4.0 Feb 28, 2023
0.3.0 Mar 23, 2022
0.2.1 Dec 24, 2021
0.1.0-dev.1 Apr 27, 2021

#201 in Asynchronous

Download history 734/week @ 2023-11-11 326/week @ 2023-11-18 533/week @ 2023-11-25 353/week @ 2023-12-02 249/week @ 2023-12-09 281/week @ 2023-12-16 190/week @ 2023-12-23 197/week @ 2023-12-30 369/week @ 2024-01-06 425/week @ 2024-01-13 356/week @ 2024-01-20 358/week @ 2024-01-27 300/week @ 2024-02-03 411/week @ 2024-02-10 418/week @ 2024-02-17 294/week @ 2024-02-24

1,532 downloads per month
Used in 10 crates (via bonsaidb-core)

MIT/Apache

21KB
411 lines

Circulate

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>()?
);

Open-source Licenses

This project, like all projects from Khonsu Labs, are open-source. This repository is available under the MIT License or the Apache License 2.0.

To learn more about contributing, please see CONTRIBUTING.md.

Dependencies

~2.4–9.5MB
~71K SLoC