Răsfoiți Sursa

Improved dump bin

Cesar Rodas 10 luni în urmă
părinte
comite
ae3a93ac55
1 a modificat fișierele cu 16 adăugiri și 8 ștergeri
  1. 16 8
      src/bin/dump.rs

+ 16 - 8
src/bin/dump.rs

@@ -19,7 +19,9 @@ fn on_connection(
     _socket: mpsc::Sender<Request>,
 ) -> Pin<Box<dyn Future<Output = ()> + Send>> {
     println!("Reconnecting to {}", host);
-    Box::pin(async move {})
+    Box::pin(async move {
+        let _ = _socket.send(Subscribe::default().into()).await;
+    })
 }
 
 #[tokio::main]
@@ -49,15 +51,21 @@ async fn main() {
     let db = RocksDb::new("./db").expect("db");
 
     loop {
-        if let Some((msg, _relayed_by)) = clients.recv().await {
+        if let Some((msg, relayed_by)) = clients.recv().await {
             match msg {
-                Event::Response(Response::Event(x)) => {
-                    let event = x.event;
-                    db.store(&event).expect("valid");
-                }
-                Event::Response(Response::EndOfStoredEvents(_)) => {}
+                Event::Response(r) => match *r {
+                    Response::Event(x) => {
+                        println!("{} => {:?}", relayed_by, x);
+                        let event = x.event;
+                        db.store(&event).expect("valid");
+                    }
+                    Response::EndOfStoredEvents(_) => {}
+                    msg => {
+                        println!("{} {:?}", relayed_by, msg);
+                    }
+                },
                 msg => {
-                    panic!("{:?}", msg);
+                    println!("{} {:?}", relayed_by, msg);
                 }
             }
         }