doido-cable 0.0.4

Action Cable analogue: channels, broadcasts, Turbo-friendly pub/sub backends for Doido.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::pubsub::PubSub;
use doido_core::Result;
use std::sync::Arc;

pub struct Cable {
    pubsub: Arc<dyn PubSub>,
}

impl Cable {
    pub fn new(pubsub: Arc<dyn PubSub>) -> Self {
        Self { pubsub }
    }

    pub async fn broadcast_to(&self, stream: &str, message: &str) -> Result<()> {
        self.pubsub.publish(stream, message).await
    }
}