Skip to content

Commit

Permalink
fix wasm builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jprochazk committed Jan 22, 2025
1 parent c4403a9 commit 0c28273
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
22 changes: 10 additions & 12 deletions crates/store/re_grpc_client/src/message_proxy/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,25 @@ struct MessageProxyAddress(String);

impl MessageProxyAddress {
fn parse(url: &str) -> Result<Self, InvalidMessageProxyAddress> {
let mut parsed = Url::parse(url).map_err(|err| InvalidMessageProxyAddress {
url: url.to_owned(),
msg: err.to_string(),
})?;

// TODO(#8761): URL prefix
if !parsed.scheme().starts_with("temp") {
let Some(url) = url.strip_prefix("temp") else {
let scheme = url.split_once("://").map(|(a, _)| a).ok_or("unknown");
return Err(InvalidMessageProxyAddress {
url: url.to_owned(),
msg: format!(
"Invalid scheme {:?}, expected {:?}",
parsed.scheme(),
"Invalid scheme {scheme:?}, expected {:?}",
// TODO(#8761): URL prefix
"temp"
),
});
}
};
let url = format!("http{url}");

parsed.set_scheme("http").ok();
let _ = Url::parse(&url).map_err(|err| InvalidMessageProxyAddress {
url: url.clone(),
msg: err.to_string(),
})?;

Ok(Self(parsed.to_string()))
Ok(Self(url))
}

fn to_http(&self) -> String {
Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_grpc_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ re_build_info.workspace = true
re_byte_size.workspace = true
re_chunk.workspace = true
re_format.workspace = true
re_log.workspace = true
re_log = { workspace = true, features = ["setup"] }
re_log_encoding = { workspace = true, features = ["encoder", "decoder"] }
re_log_types.workspace = true
re_memory.workspace = true
Expand Down
12 changes: 12 additions & 0 deletions crates/viewer/re_viewer/src/web_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ enum EndpointCategory {

/// An eventListener for rrd posted from containing html
WebEventListener(String),

#[cfg(feature = "grpc")]
// TODO(#8761): URL prefix
/// A stream of messages over gRPC, relayed from the SDK.
MessageProxy(String),
}

impl EndpointCategory {
Expand All @@ -105,6 +110,8 @@ impl EndpointCategory {
Self::WebSocket(uri)
} else if uri.starts_with("web_event:") {
Self::WebEventListener(uri)
} else if uri.starts_with("temp:") {
Self::MessageProxy(uri)
} else {
// If this is something like `foo.com` we can't know what it is until we connect to it.
// We could/should connect and see what it is, but for now we just take a wild guess instead:
Expand Down Expand Up @@ -181,6 +188,11 @@ pub fn url_to_receiver(
}
EndpointCategory::WebSocket(url) => re_data_source::connect_to_ws_url(&url, Some(ui_waker))
.with_context(|| format!("Failed to connect to WebSocket server at {url}.")),

#[cfg(feature = "grpc")]
EndpointCategory::MessageProxy(url) => {
re_grpc_client::message_proxy::read::stream(url, Some(ui_waker)).map_err(|e| e.into())
}
}
}

Expand Down

0 comments on commit 0c28273

Please sign in to comment.