Skip to content

Commit

Permalink
Fix socket with file
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed Jul 4, 2023
1 parent ac5fba9 commit 21a11aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions sea-streamer-socket/src/streamer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ impl Streamer for SeaStreamer {
.await
.map_err(map_err)?,
),
#[cfg(feature = "backend-file")]
"file" => SeaStreamerInner::File(
FileStreamer::connect(uri, options.into_file_connect_options())
.await
.map_err(map_err)?,
),
_ => {
return Err(StreamErr::Connect(format!("unknown protocol `{protocol}`")));
}
Expand Down
8 changes: 6 additions & 2 deletions sea-streamer-types/src/streamer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ impl StreamerUri {
pub fn protocol(&self) -> Option<&str> {
match self.nodes.first() {
Some(node) => {
if !node.scheme().is_empty() && node.host().is_some() {
Some(node.scheme())
if let Some((front, _)) = node.as_str().split_once("://") {
Some(front)
} else {
None
}
Expand Down Expand Up @@ -338,6 +338,10 @@ mod test {
let uri: StreamerUri = "file://./path/to/hi".parse().unwrap();
assert_eq!(uri.protocol(), Some("file"));
assert_eq!(uri.nodes(), &["file://./path/to/hi".parse().unwrap()]);

let uri: StreamerUri = "file:///path/to/hi".parse().unwrap();
assert_eq!(uri.protocol(), Some("file"));
assert_eq!(uri.nodes(), &["file:///path/to/hi".parse().unwrap()]);
}

#[test]
Expand Down

0 comments on commit 21a11aa

Please sign in to comment.