Skip to content

feat: Kotlin SDK#213

Draft
BulkBeing wants to merge 2 commits intomainfrom
kotlin-sdk
Draft

feat: Kotlin SDK#213
BulkBeing wants to merge 2 commits intomainfrom
kotlin-sdk

Conversation

@BulkBeing
Copy link
Copy Markdown
Contributor

@BulkBeing BulkBeing commented Mar 18, 2026

Provide idiomatic Kotlin APIs around existing Java SDK.

  • This PR only targets implementing the Sinker APIs and publishing the package.
  • Kotlin and Java sdk will follow different versioning (at least initially). There will be separate pipeline to publish kotlin sdk.

A sink implementation in kotlin using this sdk would look like:

import io.numaproj.numaflow.kt.sinker.*

fun main() {
    sinkServer { datums ->
        datums.processEach { datum ->
            when {
                datum.keys.isEmpty() -> datum.fallback()
                datum.value.isEmpty() -> datum.failure("empty payload")
                else -> {
                    println("Received: $datum")
                    datum.ok()
                }
            }
        }
    }.run()
}

The same would look like this if the user uses existing Java sdk in kotlin:

fun main() {
     val sinker = object : Sinker() {
         override fun processMessages(datumStream: DatumIterator): ResponseList {
             val builder = ResponseList.newBuilder()
             while (true) {
                 val datum = datumStream.next() ?: break
                 val response = when {
                     datum.keys.isNullOrEmpty() -> Response.responseFallback(datum.id)
                     datum.value == null || datum.value.isEmpty() -> Response.responseFailure(datum.id, "empty payload")
                     else -> {
                         println("Received: $datum")
                         Response.responseOK(datum.id)
                     }
                 }
                 builder.addResponse(response)
             }
             return builder.build()
         }
     }

     Server(sinker).apply {
         start()
         awaitTermination()
     }
}

NOTE: My only experience with Kotlin is reading the book "Kotlin in Action, Second Edition". So I'm expecting the sdk APIs may change a lot as I gain more experience using Kotlin and getting feedback from Kotlin devs.

Signed-off-by: Sreekanth <prsreekanth920@gmail.com>
Signed-off-by: Sreekanth <prsreekanth920@gmail.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@35d5203). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #213   +/-   ##
=======================================
  Coverage        ?   60.79%           
  Complexity      ?      561           
=======================================
  Files           ?      155           
  Lines           ?     3584           
  Branches        ?      254           
=======================================
  Hits            ?     2179           
  Misses          ?     1225           
  Partials        ?      180           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@KeranYang
Copy link
Copy Markdown
Member

@BulkBeing Thanks for doing this. Why don't we create a numaflow-kotlin repository? To me, it's cleaner with single responsibility. Having a numaflow-kotlin folder under numaflow-java repository doesn't look right to me.

@BulkBeing
Copy link
Copy Markdown
Contributor Author

@BulkBeing Thanks for doing this. Why don't we create a numaflow-kotlin repository? To me, it's cleaner with single responsibility. Having a numaflow-kotlin folder under numaflow-java repository doesn't look right to me.

I've seen some repos that provide kotlin apis with core implemented in Java having both files in same repo. In our case, I think separate repo makes sense, since we need to manage different versions (at-least initially) as Kotlin codebase will change more. Also, we need replicate all examples as well.

@vigith
Copy link
Copy Markdown
Member

vigith commented Mar 19, 2026

Let's work towards the target state. If the target state is single repo, let's just stick to single repo.

How will the artifact be published? Independently (Java and Kotlin together) or together?

@vigith
Copy link
Copy Markdown
Member

vigith commented Mar 19, 2026

nm.. I see that the artifact is separate.

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.

3 participants