#pubsub #framework #async #topic #sync #run-time #bonsai-db

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

#724 in Asynchronous

Download history 143/week @ 2024-07-21 158/week @ 2024-07-28 63/week @ 2024-08-04 59/week @ 2024-08-11 39/week @ 2024-08-18 127/week @ 2024-08-25 113/week @ 2024-09-01 84/week @ 2024-09-08 87/week @ 2024-09-15 152/week @ 2024-09-22 114/week @ 2024-09-29 18/week @ 2024-10-06 59/week @ 2024-10-13 45/week @ 2024-10-20 64/week @ 2024-10-27 52/week @ 2024-11-03

221 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.2–7.5MB
~67K SLoC