Skip to content

Commit

Permalink
dekaf: Add some important annotations to endpoint/resource schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
jshearer committed Oct 2, 2024
1 parent 271b730 commit 2b976d2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions crates/dekaf/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct DekafConfig {
/// The password that will authenticate Kafka consumers to this task.
// TODO(jshearer): Uncomment when schemars 1.0 is out and we upgrade
// #[schemars(extend("secret" = true))]
#[schemars(schema_with = "token_secret")]
pub token: String,
}

Expand All @@ -21,9 +22,25 @@ pub struct DekafConfig {
pub struct DekafResourceConfig {
/// The exposed name of the topic that maps to this binding. This
/// will be exposed through the Kafka metadata/discovery APIs.
#[schemars(schema_with = "collection_name")]
pub topic_name: String,
}

fn collection_name(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
serde_json::from_value(serde_json::json!({
"x-collection-name": true,
}))
.unwrap()
}

fn token_secret(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
serde_json::from_value(serde_json::json!({
"title": "Dekaf Auth Token",
"secret": true,
}))
.unwrap()
}

pub async fn unary_materialize(
request: materialize::Request,
) -> anyhow::Result<materialize::Response> {
Expand Down

0 comments on commit 2b976d2

Please sign in to comment.