Skip to content
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: add ssl/sasl support for kafka sink #7540

Merged
merged 13 commits into from
Feb 1, 2023
52 changes: 38 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions e2e_test/source/basic/kafka.slt
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ statement ok
create sink si
from
s5 with (
kafka.brokers = '127.0.0.1:29092',
kafka.topic = 'sink_target',
properties.bootstrap.server = '127.0.0.1:29092',
topic = 'sink_target',
format = 'append_only',
connector = 'kafka'
)
Expand Down
1 change: 1 addition & 0 deletions src/connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ bytes = { version = "1", features = ["serde"] }
chrono = { version = "0.4", default-features = false, features = ["clock", "std"] }
crc32fast = "1"
csv-core = "0.1.10"
duration-str = "0.5.0"
either = "1"
enum-as-inner = "0.5"
farmhash = "1"
Expand Down
34 changes: 34 additions & 0 deletions src/connector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
#![feature(box_into_inner)]
#![feature(type_alias_impl_trait)]

use std::time::Duration;

use duration_str::parse_std;
use serde::de;

pub mod aws_utils;
pub mod error;
mod macros;
Expand All @@ -49,3 +54,32 @@ impl ConnectorParams {
}
}
}

pub(crate) fn deserialize_bool_from_string<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: de::Deserializer<'de>,
{
let s: String = de::Deserialize::deserialize(deserializer)?;
let s = s.to_ascii_lowercase();
match s.as_str() {
"true" => Ok(true),
"false" => Ok(false),
_ => Err(de::Error::invalid_value(
de::Unexpected::Str(&s),
&"true or false",
)),
}
}

pub(crate) fn deserialize_duration_from_string<'de, D>(
deserializer: D,
) -> Result<Duration, D::Error>
where
D: de::Deserializer<'de>,
{
let s: String = de::Deserialize::deserialize(deserializer)?;
parse_std(&s).map_err(|_| de::Error::invalid_value(
de::Unexpected::Str(&s),
&"The String value unit support for one of:[“y”,“mon”,“w”,“d”,“h”,“m”,“s”, “ms”, “µs”, “ns”]",
))
}
Loading