Skip to content

Conversation

@kbatuigas
Copy link
Contributor

Description

This pull request expands the documentation for data transforms by adding a new section on multi-topic fan-out using the Go and Rust SDKs, and enhances the explanation of writing to specific output topics. The changes provide detailed, practical examples for routing and distributing messages to multiple topics, including Schema Registry integration, and clarify SDK capabilities.

Enhancements to output topic routing documentation:

  • Expanded the introductory explanation for writing records to specific output topics, highlighting use cases such as filtering, fan-out, event routing, and in-broker data distribution as alternatives to external connectors.

New multi-topic fan-out example with Schema Registry:

  • Added a comprehensive section demonstrating how to route batched updates from a single input topic to multiple output topics based on a routing field, with code samples for Go and Rust using Schema Registry wire format for schema validation.
  • Provided configuration examples and best practices for registering schemas in Schema Registry, including schema subject naming conventions and the requirement to pre-create output topics and schemas.
  • Clarified SDK support, noting that the JavaScript SDK does not support writing to specific output topics, and directing users to Go or Rust for multi-topic fan-out.

Resolves https://redpandadata.atlassian.net/browse/
Review deadline:

Page previews

Checks

  • New feature
  • Content gap
  • Support Follow-up
  • Small fix (typos, links, copyedits, etc)

@kbatuigas kbatuigas requested a review from a team as a code owner January 28, 2026 02:27
@netlify
Copy link

netlify bot commented Jan 28, 2026

Deploy Preview for redpanda-docs-preview ready!

Name Link
🔨 Latest commit 0edf570
🔍 Latest deploy log https://app.netlify.com/projects/redpanda-docs-preview/deploys/69797411fe3dcb0008a94efb
😎 Deploy Preview https://deploy-preview-1563--redpanda-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

This documentation update expands the data transforms guide with new content on routing and fan-out patterns. The changes add a dedicated multi-topic fan-out section that provides end-to-end examples in Go, Rust, and JavaScript, demonstrating how to route records from a single input topic to multiple output topics. The examples include Schema Registry integration, batched updates with routing fields, and per-topic schema ID handling. JavaScript guidance is updated to clarify that multi-topic fan-out is not supported by its SDK.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is vague and does not accurately reflect the main content, which focuses on multi-topic fan-out documentation enhancements rather than a WASM-specific example. Revise the title to be more specific and descriptive, such as 'Add multi-topic fan-out example with Go and Rust SDKs and Schema Registry integration' to better reflect the actual documentation changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description covers most required template sections and provides detailed explanations of the changes, but the JIRA ticket placeholder remains unfilled and page preview links are missing.
Linked Issues check ✅ Passed The PR fulfills DOC-1898 by providing a comprehensive fan-out example demonstrating routing and filtering of messages to multiple topics using Go and Rust SDKs with Schema Registry integration.
Out of Scope Changes check ✅ Passed All changes directly support the fan-out documentation objective, including expanded routing explanations, multi-topic examples, schema registration guidance, and SDK capability clarifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • PREVIEW-487: Request failed with status code 404

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
modules/develop/pages/data-transforms/build.adoc (1)

432-437: Fix undefined identifiers in Go JSON validation example.

w and e are undefined; should use writer and event. This will fail for readers copying the snippet.

🐛 Proposed fix
-	if json.Valid(event.Record().Value) {
-		return w.Write(e.Record())
+	if json.Valid(event.Record().Value) {
+		return writer.Write(event.Record())
 	}
 	// Send invalid records to separate topic
-	return writer.Write(e.Record(), transform.ToTopic("invalid-json"))
+	return writer.Write(event.Record(), transform.ToTopic("invalid-json"))
🧹 Nitpick comments (2)
modules/develop/pages/data-transforms/build.adoc (2)

489-504: Use xref with empty brackets for link text.

Project guidance prefers xref:...[] so the target title renders automatically. Please update the new links in this block.

♻️ Proposed fix
-xref:develop:data-transforms/configure.adoc[Configure the transform] with multiple output topics:
+xref:develop:data-transforms/configure.adoc[] with multiple output topics:

-NOTE: xref:manage:schema-reg/schema-reg-api.adoc[Register schemas in Schema Registry] before deploying the transform.
+NOTE: xref:manage:schema-reg/schema-reg-api.adoc[] before deploying the transform.

Based on learnings, “AsciiDoc linking: prefer using xref links with empty brackets (e.g., xref:section/target.adoc[]) because the title is pulled from the referenced document automatically. Avoid hard-coding link text; use xref:...[] to let the target document's title render as the link text when publishing.”


645-686: Refactor static mut + unsafe to OnceLock for safer, idiomatic Rust.

This example unnecessarily introduces unsafe code in the documentation. Since the Rust version requirement is "the latest stable version," std::sync::OnceLock (stabilized in Rust 1.70.0) is available and should be preferred as the idiomatic approach.

♻️ Proposed fix (OnceLock)
-use std::collections::HashMap;
-use std::error::Error;
+use std::collections::HashMap;
+use std::error::Error;
+use std::sync::OnceLock;

-// Schema IDs for each output topic obtained from Schema Registry
-// Register schemas before deploying the transform using the {topic-name}-value naming convention
-static mut SCHEMA_IDS: Option<HashMap<String, i32>> = None;
+// Schema IDs for each output topic obtained from Schema Registry
+// Register schemas before deploying the transform using the {topic-name}-value naming convention
+static SCHEMA_IDS: OnceLock<HashMap<String, i32>> = OnceLock::new();

 fn main() {
     let mut schema_ids = HashMap::new();
     schema_ids.insert("orders".to_string(), 1);
     schema_ids.insert("inventory".to_string(), 2);
     schema_ids.insert("customers".to_string(), 3);

-    unsafe {
-        SCHEMA_IDS = Some(schema_ids);
-    }
+    let _ = SCHEMA_IDS.set(schema_ids);

     on_record_written(route_updates);
 }

 fn route_updates(event: WriteEvent, writer: &mut RecordWriter) -> Result<(), Box<dyn Error>> {
     let batch: BatchMessage = serde_json::from_slice(event.record.value().unwrap_or_default())?;
-    let schema_ids = unsafe { SCHEMA_IDS.as_ref().unwrap() };
+    let schema_ids = SCHEMA_IDS.get().unwrap();

     for update in batch.updates.iter() {
         if let Some(&schema_id) = schema_ids.get(&update.table) {
             write_update(update, schema_id, writer, &event)?;
         }
     }

@kbatuigas kbatuigas marked this pull request as draft January 28, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants