Skip to content

Commit db0fc7c

Browse files
authored
rust(feat): Get FlowDescriptor, send_requests_nonblocking (#403)
1 parent 5a5462e commit db0fc7c

3 files changed

Lines changed: 60 additions & 6 deletions

File tree

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ members = [
1313

1414
[workspace.package]
1515
authors = ["Sift Software Engineers <engineering@siftstack.com>"]
16-
version = "0.7.0-rc.5"
16+
version = "0.7.0-rc.6"
1717
edition = "2024"
1818
categories = ["aerospace", "science::robotics"]
1919
homepage = "https://github.com/sift-stack/sift"
@@ -27,11 +27,11 @@ chrono = { version = "0.4.39", default-features = false, features = ["clock"] }
2727
pbjson-types = "^0.7"
2828
tonic = { version = "^0.12", features = ["gzip"] }
2929

30-
sift_connect = { version = "0.7.0-rc.5", path = "rust/crates/sift_connect" }
31-
sift_rs = { version = "0.7.0-rc.5", path = "rust/crates/sift_rs" }
32-
sift_error = { version = "0.7.0-rc.5", path = "rust/crates/sift_error" }
33-
sift_stream = { version = "0.7.0-rc.5", path = "rust/crates/sift_stream" }
34-
sift_pbfs = { version = "0.7.0-rc.5", path = "rust/crates/sift_pbfs" }
30+
sift_connect = { version = "0.7.0-rc.6", path = "rust/crates/sift_connect" }
31+
sift_rs = { version = "0.7.0-rc.6", path = "rust/crates/sift_rs" }
32+
sift_error = { version = "0.7.0-rc.6", path = "rust/crates/sift_error" }
33+
sift_stream = { version = "0.7.0-rc.6", path = "rust/crates/sift_stream" }
34+
sift_pbfs = { version = "0.7.0-rc.6", path = "rust/crates/sift_pbfs" }
3535

3636
sift_stream_bindings = { version = "0.1.0", path = "rust/crates/sift_stream_bindings" }
3737

rust/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file.
33

44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [v0.7.0-rc.6] - November 24, 2025
7+
### What's New
8+
#### SiftStream APIs to Utilize `FlowDescriptor` and `FlowBuilder`
9+
Two new APIs have been added to allow use of the `FlowDescriptor` and `FlowBuilder` structs added
10+
previously.
11+
12+
### Full Changelog
13+
- [Get FlowDescriptor, send_requests_nonblocking]()
14+
15+
616
## [v0.7.0-rc.5] - November 24, 2025
717
### What's New
818
#### SiftStream FlowDescriptors and FlowBuilders

rust/crates/sift_stream/src/stream/mode/ingestion_config.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::super::{SiftStream, SiftStreamMode, channel::ChannelValue, time::TimeValue};
22
use crate::{
3+
FlowDescriptor,
34
metrics::SiftStreamMetrics,
45
stream::{
56
run::{RunSelector, load_run_by_form, load_run_by_id},
@@ -213,6 +214,27 @@ impl SiftStream<IngestionConfigMode> {
213214
Ok(())
214215
}
215216

217+
/// This method offers a way to send data in a manner that's identical to the raw
218+
/// [`gRPC service`] for ingestion-config based streaming. Users are expected to handle
219+
/// channel value ordering as well as empty values correctly.
220+
///
221+
/// ### Important
222+
///
223+
/// Note if using this interface, you should use [FlowBuilder::request] to ensure proper
224+
/// building of the request.
225+
///
226+
/// [`gRPC service`]: https://github.com/sift-stack/sift/blob/main/protos/sift/ingest/v1/ingest.proto#L11
227+
pub fn send_requests_nonblocking<I>(&mut self, requests: I) -> Result<()>
228+
where
229+
I: IntoIterator<Item = IngestWithConfigDataStreamRequest>,
230+
{
231+
for req in requests {
232+
self.metrics.messages_received.increment();
233+
self.send_impl(req)?;
234+
}
235+
Ok(())
236+
}
237+
216238
/// Concerned with sending the actual ingest request to [DataStream] which will then write it
217239
/// to the gRPC stream. If backups are enabled, the request will be backed up as well.
218240
fn send_impl(&mut self, request: IngestWithConfigDataStreamRequest) -> Result<()> {
@@ -368,6 +390,28 @@ impl SiftStream<IngestionConfigMode> {
368390
.collect()
369391
}
370392

393+
/// Get the flow descriptor for a given flow name.
394+
pub fn get_flow_descriptor(&self, flow_name: &str) -> Result<FlowDescriptor<String>> {
395+
let Some(flow) = self.mode.flows_by_name.get(flow_name) else {
396+
return Err(Error::new_msg(
397+
ErrorKind::NotFoundError,
398+
format!("flow '{}' not found", flow_name),
399+
));
400+
};
401+
402+
if flow.is_empty() {
403+
return Err(Error::new_msg(
404+
ErrorKind::NotFoundError,
405+
format!("flow '{}' not found", flow_name),
406+
));
407+
}
408+
409+
FlowDescriptor::try_from((
410+
self.mode.ingestion_config.ingestion_config_id.clone(),
411+
&flow[0],
412+
))
413+
}
414+
371415
/// Attach a run to the stream. Any data provided through [SiftStream::send] after return
372416
/// of this function will be associated with the run.
373417
pub async fn attach_run(&mut self, run_selector: RunSelector) -> Result<()> {

0 commit comments

Comments
 (0)