Skip to content

KTOR-9406 Add code sample projects for I/O Interoperability#807

Open
Seongju-Lee wants to merge 2 commits into
ktorio:mainfrom
Seongju-Lee:ktor-9406-io-interop-samples
Open

KTOR-9406 Add code sample projects for I/O Interoperability#807
Seongju-Lee wants to merge 2 commits into
ktorio:mainfrom
Seongju-Lee:ktor-9406-io-interop-samples

Conversation

@Seongju-Lee
Copy link
Copy Markdown

Description

Add runnable Gradle subprojects (client-io-interop, server-io-interop) demonstrating the four
adapters documented on the I/O Interoperability page,
migrate the page's inline code blocks to {src=...} references, and add a <tldr> element linking to
both samples.

Verification

  • ./gradlew :client-io-interop:run and :server-io-interop:run
  • ./gradlew :server-io-interop:test
  • Full ./gradlew test --rerun-tasks --continue: no new failures

Related issue

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 683fa5b1-77ac-40d9-bebd-50a14861c522

📥 Commits

Reviewing files that changed from the base of the PR and between d637d8d and de0e3ed.

📒 Files selected for processing (1)
  • codeSnippets/snippets/client-io-interop/src/main/kotlin/com/example/Application.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • codeSnippets/snippets/client-io-interop/src/main/kotlin/com/example/Application.kt

Walkthrough

Adds two new code snippet modules—client-io-interop and server-io-interop—to the Gradle settings, implements a client sample and a server sample (with tests and Logback), adds READMEs for each, and updates topics/io-interoperability.md to include external snippet references to those samples.

Changes

I/O Interoperability Samples

Layer / File(s) Summary
Gradle Module Registration
codeSnippets/settings.gradle.kts
Registers two new snippet submodules: snippets:client-io-interop and snippets:server-io-interop.
Build Configuration
codeSnippets/snippets/client-io-interop/build.gradle.kts, codeSnippets/snippets/server-io-interop/build.gradle.kts
Adds Kotlin/JVM application builds, sets com.example.ApplicationKt as main class, configures mavenCentral() and Ktor EAP repo, and declares Ktor/Logback/Kotlin dependencies.
Client Sample Implementation
codeSnippets/snippets/client-io-interop/src/main/kotlin/com/example/Application.kt
Adds main() creating a CIO HttpClient, GETs https://httpbin.org/bytes/1024, converts response ByteReadChannelRawSource via .asSource(), reads and prints the first byte, and closes the client.
Client README
codeSnippets/snippets/client-io-interop/README.md
Introduces the sample, describes .asSource() bridging, and provides a run instruction (./gradlew :client-io-interop:run).
Server Sample Implementation
codeSnippets/snippets/server-io-interop/src/main/kotlin/com/example/Application.kt
Adds main() and Application.module() starting embedded Netty server on port 8080 with routes /sink, /raw-sink, and /output-stream that write bytes via RawSink, buffer-backed ByteWriteChannel, and OutputStream.asByteWriteChannel() respectively.
Server Build & Resources
codeSnippets/snippets/server-io-interop/build.gradle.kts, .../src/main/resources/logback.xml
Adds application build config and Logback config (console appender, root trace, Jetty/Netty INFO).
Server Tests
codeSnippets/snippets/server-io-interop/src/test/kotlin/com/example/ApplicationTest.kt
Adds three integration tests using testApplication that call /sink, /raw-sink, and /output-stream, asserting 200 OK and expected response bodies (text or exact bytes).
Server README
codeSnippets/snippets/server-io-interop/README.md
Documents the three routes, adapters used (asSink(), RawSink.asByteWriteChannel(), OutputStream.asByteWriteChannel()), run and curl examples.
Docs Update
topics/io-interoperability.md
Adds a TLDR linking to the two snippet directories and replaces inline Kotlin examples with external snippet includes referencing the new samples.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • vnikolova
  • e5l
  • bjhham
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main objective: adding code sample projects for I/O interoperability, which aligns with the changeset of two new Gradle subprojects and documentation updates.
Description check ✅ Passed The description is directly related to the changeset, explaining the addition of two runnable Gradle subprojects, code migration to external references, and documentation updates, with verification steps included.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@codeSnippets/snippets/client-io-interop/src/main/kotlin/com/example/Application.kt`:
- Around line 13-23: The HttpClient instance (client) is created but never
closed, which can leak engine threads; after the runBlocking { ... } block that
uses client.prepareGet and executes the request, call client.close() to release
resources (ensure the close happens regardless of exceptions—e.g., close client
after runBlocking or use a try/finally around runBlocking) so HttpClient(CIO) is
properly shut down.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e4b11371-470a-4b84-992b-038831220cf4

📥 Commits

Reviewing files that changed from the base of the PR and between e76df17 and d637d8d.

📒 Files selected for processing (10)
  • codeSnippets/settings.gradle.kts
  • codeSnippets/snippets/client-io-interop/README.md
  • codeSnippets/snippets/client-io-interop/build.gradle.kts
  • codeSnippets/snippets/client-io-interop/src/main/kotlin/com/example/Application.kt
  • codeSnippets/snippets/server-io-interop/README.md
  • codeSnippets/snippets/server-io-interop/build.gradle.kts
  • codeSnippets/snippets/server-io-interop/src/main/kotlin/com/example/Application.kt
  • codeSnippets/snippets/server-io-interop/src/main/resources/logback.xml
  • codeSnippets/snippets/server-io-interop/src/test/kotlin/com/example/ApplicationTest.kt
  • topics/io-interoperability.md

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.

1 participant