risingwave_connector/source/kinesis/
mod.rspub mod enumerator;
pub mod source;
pub mod split;
use std::collections::HashMap;
use serde::Deserialize;
use serde_with::{serde_as, DisplayFromStr};
pub use source::KinesisMeta;
use with_options::WithOptions;
use crate::connector_common::KinesisCommon;
use crate::source::kinesis::enumerator::client::KinesisSplitEnumerator;
use crate::source::kinesis::source::reader::KinesisSplitReader;
use crate::source::kinesis::split::KinesisSplit;
use crate::source::SourceProperties;
pub const KINESIS_CONNECTOR: &str = "kinesis";
#[serde_as]
#[derive(Clone, Debug, Deserialize, WithOptions)]
pub struct KinesisProperties {
#[serde(rename = "scan.startup.mode", alias = "kinesis.scan.startup.mode")]
pub scan_startup_mode: Option<String>,
#[serde(rename = "scan.startup.timestamp.millis")]
#[serde_as(as = "Option<DisplayFromStr>")]
pub start_timestamp_millis: Option<i64>,
#[serde(flatten)]
pub common: KinesisCommon,
#[serde(flatten)]
pub unknown_fields: HashMap<String, String>,
}
impl SourceProperties for KinesisProperties {
type Split = KinesisSplit;
type SplitEnumerator = KinesisSplitEnumerator;
type SplitReader = KinesisSplitReader;
const SOURCE_NAME: &'static str = KINESIS_CONNECTOR;
}
impl crate::source::UnknownFields for KinesisProperties {
fn unknown_fields(&self) -> HashMap<String, String> {
self.unknown_fields.clone()
}
}
#[cfg(test)]
mod test {
use maplit::hashmap;
use super::*;
#[test]
fn test_parse_kinesis_timestamp_offset() {
let props: HashMap<String, String> = hashmap! {
"stream".to_string() => "sample_stream".to_string(),
"aws.region".to_string() => "us-east-1".to_string(),
"scan_startup_mode".to_string() => "timestamp".to_string(),
"scan.startup.timestamp.millis".to_string() => "123456789".to_string(),
};
let kinesis_props: KinesisProperties =
serde_json::from_value(serde_json::to_value(props).unwrap()).unwrap();
assert_eq!(kinesis_props.start_timestamp_millis, Some(123456789));
}
}