-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Implement Sourcer
traits for serving source
#2301
Changes from 14 commits
3a45e5f
198fe00
94dcddd
ae42c29
bdb8243
0bc6ca9
e20b022
f548609
ca8cdeb
76c2371
57c4cb7
e893964
a45411d
e8592bc
54c2cce
8f0389b
d85079a
1dcad81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ pub(crate) mod source { | |
|
||
use std::collections::HashMap; | ||
use std::env; | ||
use std::sync::Arc; | ||
use std::{fmt::Debug, time::Duration}; | ||
|
||
use bytes::Bytes; | ||
|
@@ -37,7 +38,7 @@ pub(crate) mod source { | |
Generator(GeneratorConfig), | ||
UserDefined(UserDefinedConfig), | ||
Pulsar(PulsarSourceConfig), | ||
Serving(serving::Settings), | ||
Serving(Arc<serving::Settings>), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why |
||
} | ||
|
||
impl From<Box<GeneratorSource>> for SourceType { | ||
|
@@ -110,10 +111,7 @@ pub(crate) mod source { | |
// There should be only one option (user-defined) to define the settings. | ||
fn try_from(cfg: Box<numaflow_models::models::ServingSource>) -> Result<Self> { | ||
let env_vars = env::vars().collect::<HashMap<String, String>>(); | ||
|
||
let mut settings: serving::Settings = env_vars | ||
.try_into() | ||
.map_err(|e: serving::Error| Error::Config(e.to_string()))?; | ||
let mut settings: serving::Settings = env_vars.try_into()?; | ||
|
||
settings.tid_header = cfg.msg_id_header_key; | ||
|
||
|
@@ -148,7 +146,7 @@ pub(crate) mod source { | |
} | ||
settings.redis.addr = cfg.store.url; | ||
|
||
Ok(SourceType::Serving(settings)) | ||
Ok(SourceType::Serving(Arc::new(settings))) | ||
} | ||
} | ||
|
||
|
@@ -168,6 +166,10 @@ pub(crate) mod source { | |
return pulsar.try_into(); | ||
} | ||
|
||
if let Some(serving) = source.serving.take() { | ||
return serving.try_into(); | ||
} | ||
|
||
Err(Error::Config(format!("Invalid source type: {source:?}"))) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ mod tracker; | |
mod mapper; | ||
|
||
pub async fn run() -> Result<()> { | ||
let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this for? please document |
||
let cln_token = CancellationToken::new(); | ||
let shutdown_cln_token = cln_token.clone(); | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,9 +1,11 @@ | ||||||
use std::sync::Arc; | ||||||
use std::time::Duration; | ||||||
|
||||||
use numaflow_pb::clients::map::map_client::MapClient; | ||||||
use numaflow_pb::clients::sink::sink_client::SinkClient; | ||||||
use numaflow_pb::clients::source::source_client::SourceClient; | ||||||
use numaflow_pb::clients::sourcetransformer::source_transform_client::SourceTransformClient; | ||||||
use serving::ServingSource; | ||||||
use tokio_util::sync::CancellationToken; | ||||||
use tonic::transport::Channel; | ||||||
|
||||||
|
@@ -334,8 +336,17 @@ pub async fn create_source( | |||||
None, | ||||||
)) | ||||||
} | ||||||
SourceType::Serving(_) => { | ||||||
unimplemented!("Serving as built-in source is not yet implemented") | ||||||
SourceType::Serving(config) => { | ||||||
let serving = ServingSource::new(Arc::clone(config), batch_size, read_timeout).await?; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
why clone, can't we give the ownership? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||
Ok(( | ||||||
Source::new( | ||||||
batch_size, | ||||||
source::SourceType::Serving(serving), | ||||||
tracker_handle, | ||||||
source_config.read_ahead, | ||||||
), | ||||||
None, | ||||||
)) | ||||||
} | ||||||
} | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no longer valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted. Had commented it out for faster image builds on laptop.