sentinel_driver/connection/
notify_impl.rs1use super::{notify, Connection, Notification, Result};
2
3impl Connection {
4 pub async fn listen(&mut self, channel: &str) -> Result<()> {
6 notify::listen(&mut self.conn, channel).await
7 }
8
9 pub async fn unlisten(&mut self, channel: &str) -> Result<()> {
11 notify::unlisten(&mut self.conn, channel).await
12 }
13
14 pub async fn unlisten_all(&mut self) -> Result<()> {
16 notify::unlisten_all(&mut self.conn).await
17 }
18
19 pub async fn notify(&mut self, channel: &str, payload: &str) -> Result<()> {
21 notify::notify(&mut self.conn, channel, payload).await
22 }
23
24 pub async fn wait_for_notification(&mut self) -> Result<Notification> {
35 let res = notify::wait_for_notification(&mut self.conn).await;
36 if let Ok(n) = &res {
37 self.instr().on_event(&crate::Event::Notification {
38 channel: &n.channel,
39 payload: &n.payload,
40 pid: n.process_id,
41 });
42 }
43 res
44 }
45}