Skip to content

Commit

Permalink
feat: Log block stream requests
Browse files Browse the repository at this point in the history
  • Loading branch information
morgsmccauley committed Dec 21, 2023
1 parent 4afa174 commit 3e8307e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
1 change: 1 addition & 0 deletions coordinator/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ redis = { version = "0.24", features = ["tokio-comp", "connection-manager"] }
tokio = "1.28"
tonic = "0.10.2"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
serde_json = "1.0.108"

block-streamer = { path = "../block-streamer" }
Expand Down
30 changes: 16 additions & 14 deletions coordinator/src/block_streams_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ impl BlockStreamsHandlerImpl {
}

pub async fn stop(&mut self, stream_id: String) -> anyhow::Result<()> {
let _ = self
.client
.stop_stream(Request::new(StopStreamRequest { stream_id }))
.await?;
let request = Request::new(StopStreamRequest { stream_id });

tracing::debug!("Sending stop stream request: {:#?}", request);

let _ = self.client.stop_stream(request).await?;

Ok(())
}
Expand Down Expand Up @@ -85,16 +86,17 @@ impl BlockStreamsHandlerImpl {
}
};

let _ = self
.client
.start_stream(Request::new(StartStreamRequest {
start_block_height,
account_id,
function_name,
version,
rule: Some(rule),
}))
.await?;
let request = Request::new(StartStreamRequest {
start_block_height,
account_id,
function_name,
version,
rule: Some(rule),
});

tracing::debug!("Sending start stream request: {:#?}", request);

let _ = self.client.start_stream(request).await?;

Ok(())
}
Expand Down
8 changes: 7 additions & 1 deletion coordinator/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use tracing_subscriber::prelude::*;

use crate::block_streams_handler::BlockStreamsHandler;
use crate::redis::RedisClient;
use crate::registry::Registry;
Expand All @@ -8,7 +10,11 @@ mod registry;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let registry = Registry::connect("https://rpc.mainnet.near.org");
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(tracing_subscriber::EnvFilter::from_default_env())
.init();

let redis_client = RedisClient::connect("redis://127.0.0.1").await?;
let mut block_stream_handler = BlockStreamsHandler::connect().await?;

Expand Down

0 comments on commit 3e8307e

Please sign in to comment.