Skip to main content

apollo/channels/
http_inject.rs

1use async_trait::async_trait;
2use tokio::sync::mpsc;
3
4use super::traits::{Channel, IncomingMessage, OutgoingMessage};
5
6pub struct HttpInjectChannel;
7
8impl Default for HttpInjectChannel {
9    fn default() -> Self {
10        Self::new()
11    }
12}
13
14impl HttpInjectChannel {
15    pub fn new() -> Self {
16        Self
17    }
18}
19
20#[async_trait]
21impl Channel for HttpInjectChannel {
22    fn name(&self) -> &str {
23        "http"
24    }
25
26    async fn start(&mut self) -> anyhow::Result<mpsc::Receiver<IncomingMessage>> {
27        let (_tx, rx) = mpsc::channel(1);
28        Ok(rx)
29    }
30
31    async fn send(&self, message: OutgoingMessage) -> anyhow::Result<Option<String>> {
32        tracing::debug!(target: "apollo::http", chars = message.text.chars().count(), "reply");
33        Ok(None)
34    }
35
36    async fn stop(&mut self) -> anyhow::Result<()> {
37        Ok(())
38    }
39}