kabu_core_actors/lib.rs
1pub use actor::{Accessor, Actor, ActorResult, Consumer, Producer, WorkerResult};
2pub use actor_manager::ActorsManager;
3pub use channels::{Broadcaster, MultiProducer};
4pub use shared_state::SharedState;
5
6mod actor;
7mod actor_manager;
8mod channels;
9mod shared_state;
10
11#[macro_export]
12macro_rules! run_async {
13 ($fx:expr) => {
14 match $fx.await {
15 Ok(_) => {}
16 Err(e) => error!("ERROR_RUNNING_ASYNC"),
17 }
18 };
19}
20
21#[macro_export]
22macro_rules! run_sync {
23 ($fx:expr) => {
24 match $fx {
25 Ok(_) => {}
26 Err(error) => tracing::error!(%error, "ERROR_RUNNING_SYNC"),
27 }
28 };
29}
30
31#[inline]
32pub fn subscribe_helper<A: Clone + Send + Sync>(broadcaster: &Broadcaster<A>) -> tokio::sync::broadcast::Receiver<A> {
33 broadcaster.subscribe()
34}
35
36#[macro_export]
37macro_rules! subscribe {
38 ($name:ident) => {
39 let mut $name = $crate::subscribe_helper(&$name);
40 };
41}