Skip to content

Commit 2f34ceb

Browse files
patrickelectricjoaoantoniocardoso
authored andcommitted
lib: driver: fake: Fix fake source running as sink
Signed-off-by: Patrick José Pereira <[email protected]>
1 parent 9c6b949 commit 2f34ceb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/lib/drivers/fake.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,21 @@ impl DriverInfo for FakeSourceInfo {
323323
]
324324
}
325325

326-
fn create_endpoint_from_url(&self, _url: &url::Url) -> Option<Arc<dyn Driver>> {
327-
Some(Arc::new(FakeSink::builder("Unnamed").print().build()))
326+
fn create_endpoint_from_url(&self, url: &url::Url) -> Option<Arc<dyn Driver>> {
327+
let period: u64 = url
328+
.query_pairs()
329+
.find_map(|(key, value)| {
330+
if key == "period" {
331+
value.parse().ok()
332+
} else {
333+
None
334+
}
335+
})
336+
.unwrap_or(10);
337+
338+
Some(Arc::new(
339+
FakeSource::builder("Unnamed", std::time::Duration::from_millis(period)).build(),
340+
))
328341
}
329342
}
330343

0 commit comments

Comments
 (0)