built-paths subscription: better heuristic for sipping event frames
This commit is contained in:
parent
c0b8f7b57b
commit
594748fe30
|
@ -363,18 +363,15 @@ async fn main_cli() -> Result<()> {
|
||||||
let mut data = response.into_data_stream();
|
let mut data = response.into_data_stream();
|
||||||
|
|
||||||
while let Some(event_str) = data.next().await {
|
while let Some(event_str) = data.next().await {
|
||||||
tracing::info!("got {:?}", event_str);
|
let event_str = event_str.unwrap(); // TODO(colemickens): error handle
|
||||||
// TOOD: skip our keep-alive, maybe we should set it, we rely on the axum default "\n\n" right now
|
|
||||||
// but we need to skip those lines, anyway, and not bother trying to parse them
|
|
||||||
|
|
||||||
// TODO(colemickens): error handle
|
let event_str = match event_str.strip_prefix("data: ".as_bytes()) {
|
||||||
let event_str = event_str.unwrap();
|
Some(s) => s,
|
||||||
if event_str == "\n\n" {
|
None => {
|
||||||
// TODO: hacky, could be better
|
tracing::debug!("built-paths subscription: ignoring non-data frame");
|
||||||
continue
|
continue;
|
||||||
}
|
},
|
||||||
// TOOD: another sorta hack
|
};
|
||||||
let event_str = event_str.strip_prefix("data: ".as_bytes()).unwrap(); // TODO: omg
|
|
||||||
let event: BuiltPathResponseEventV1 = serde_json::from_slice(&event_str)?;
|
let event: BuiltPathResponseEventV1 = serde_json::from_slice(&event_str)?;
|
||||||
|
|
||||||
// TODO(colemickens): error handling:::
|
// TODO(colemickens): error handling:::
|
||||||
|
@ -382,7 +379,8 @@ async fn main_cli() -> Result<()> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|path| state.store.follow_store_path(path).map_err(|_| anyhow!("ahhhhh")))
|
.map(|path| state.store.follow_store_path(path).map_err(|_| anyhow!("ahhhhh")))
|
||||||
.collect::<Result<Vec<_>>>()?;
|
.collect::<Result<Vec<_>>>()?;
|
||||||
|
|
||||||
|
tracing::debug!("about to enqueue paths: {:?}", store_paths);
|
||||||
crate::api::enqueue_paths(&state, store_paths).await?;
|
crate::api::enqueue_paths(&state, store_paths).await?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue