Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/kotlin-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Publishes the Kotlin SDK to Maven Central and GitHub Packages.
# Triggered by GitHub releases with tags matching kotlin-v* (e.g. kotlin-v0.1.0).

name: Publish Kotlin SDK to Maven Central and Github Packages
on:
release:
types: [ created ]
jobs:
publish:
if: startsWith(github.event.release.tag_name, 'kotlin-v')
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v3
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}

# Build the Java SDK first so it's available as a local dependency
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
settings-path: ${{ github.workspace }}

- name: Install Java SDK to local repository
run: mvn clean install -DskipTests -q

- name: Publish Kotlin SDK to Maven Central
run: cd numaflow-kotlin && mvn -DcentralRelease=true -P central deploy -s $GITHUB_WORKSPACE/settings.xml
env:
MAVEN_USERNAME: ${{ secrets.MVN_CENTRAL_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MVN_CENTRAL_PASSWORD }}

- name: Set up Java for publishing to GitHub Packages
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
server-id: github
settings-path: ${{ github.workspace }}

- name: Publish Kotlin SDK to GitHub Packages
run: cd numaflow-kotlin && mvn -DgithubRelease=true -P github deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
11 changes: 7 additions & 4 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# This workflow will build a package using Maven and then publish it to Maven Central and GitHub packages when a release is created
# Triggered by tags matching v* (e.g. v0.11.0). Kotlin SDK uses a separate workflow.

name: Publish to Maven Central and Github Packages
name: Publish Java SDK to Maven Central and Github Packages
on:
release:
types: [ created ]
jobs:
publish:
if: startsWith(github.event.release.tag_name, 'v') && !startsWith(github.event.release.tag_name, 'v-kotlin')
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -28,7 +30,7 @@ jobs:
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
settings-path: ${{ github.workspace }} # location for the settings.xml file
settings-path: ${{ github.workspace }}

- name: Publish to the Maven Central Repository
run: mvn -DcentralRelease=true -P central deploy -s $GITHUB_WORKSPACE/settings.xml
Expand All @@ -41,8 +43,9 @@ jobs:
with:
java-version: '11'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} #location for the settings.xml file
server-id: github
settings-path: ${{ github.workspace }}

- name: Publish to GitHub Packages
run: mvn -DgithubRelease=true -P github deploy -s $GITHUB_WORKSPACE/settings.xml
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Compiled class file
*.class

numaflow-kotlin/target/

# Log file
*.log

Expand Down
242 changes: 242 additions & 0 deletions numaflow-kotlin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.numaproj.numaflow</groupId>
<artifactId>numaflow-kotlin</artifactId>
<version>0.1.0</version>
<packaging>jar</packaging>

<name>numaflow-kotlin</name>
<description>Kotlin wrapper for Numaflow Java SDK — coroutines, Flow, sealed classes, DSL builders.</description>
<url>https://numaflow.numaproj.io/</url>

<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<developers>
<developer>
<name>Numaproj Authors</name>
<email>numaproj@gmail.com</email>
<organization>Numaproj</organization>
<organizationUrl>https://numaproj.io/</organizationUrl>
</developer>
</developers>

<scm>
<connection>scm:git:git://github.com/numaproj/numaflow-java.git</connection>
<developerConnection>scm:git:ssh://github.com:numaproj/numaflow-java.git</developerConnection>
<url>http://github.com/numaproj/numaflow-java/tree/main</url>
</scm>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>2.1.0</kotlin.version>
<kotlinx.coroutines.version>1.9.0</kotlinx.coroutines.version>
<junit.jupiter.version>5.10.2</junit.jupiter.version>
</properties>

<profiles>
<profile>
<id>github</id>
<activation>
<property>
<name>githubRelease</name>
<value>true</value>
</property>
</activation>
<distributionManagement>
<repository>
<id>github</id>
<name>Numaflow Kotlin SDK</name>
<url>https://maven.pkg.github.com/numaproj/numaflow-java</url>
</repository>
</distributionManagement>
</profile>
<profile>
<id>central</id>
<activation>
<property>
<name>centralRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.8.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<dependencies>
<!-- Numaflow Java SDK -->
<dependency>
<groupId>io.numaproj.numaflow</groupId>
<artifactId>numaflow-java</artifactId>
<version>0.11.0</version>
</dependency>

<!-- Kotlin -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
<version>${kotlinx.coroutines.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-jdk8</artifactId>
<version>${kotlinx.coroutines.version}</version>
</dependency>

<!-- Test -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-test</artifactId>
<version>${kotlinx.coroutines.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>

<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>11</jvmTarget>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>1.9.20</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>dokka</goal>
<goal>javadocJar</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.numaproj.numaflow.kt.sinker

import io.numaproj.numaflow.shared.UserMetadata
import io.numaproj.numaflow.sinker.Message as JavaMessage
import io.numaproj.numaflow.sinker.Response as JavaResponse

internal fun SinkResponse.toJava(): JavaResponse = when (this) {
is SinkResponse.Ok -> JavaResponse.responseOK(id)
is SinkResponse.Failure -> JavaResponse.responseFailure(id, error)
is SinkResponse.Fallback -> JavaResponse.responseFallback(id)
is SinkResponse.Serve -> JavaResponse.responseServe(id, data)
is SinkResponse.OnSuccess -> JavaResponse.responseOnSuccess(id, message?.toJava())
}

internal fun SinkMessage.toJava(): JavaMessage = JavaMessage(
value,
keys.toTypedArray(),
userMetadata ?: UserMetadata(),
)

internal fun JavaResponse.toKotlin(): SinkResponse {
return when {
success == true -> SinkResponse.Ok(id)
fallback == true -> SinkResponse.Fallback(id)
serve == true -> SinkResponse.Serve(id, serveResponse ?: byteArrayOf())
onSuccess == true -> SinkResponse.OnSuccess(
id,
onSuccessMessage?.let { msg ->
SinkMessage(
value = msg.value ?: byteArrayOf(),
keys = msg.keys?.toList() ?: emptyList(),
userMetadata = msg.userMetadata,
)
},
)
else -> SinkResponse.Failure(id, err ?: "unknown error")
}
}
Loading
Loading