Bladeren bron

Improved dump bin

Cesar Rodas 10 maanden geleden
bovenliggende
commit
ae3a93ac55
1 gewijzigde bestanden met toevoegingen van 16 en 8 verwijderingen
  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);
                 }
             }
         }