├── .gitattributes ├── .github ├── renovate.json5 └── workflows │ ├── run_gradle_task.yml │ ├── run_publish_maven.yml │ ├── run_publish_site.yml │ ├── run_tests.yml │ ├── workflow_pull_request.yml │ └── workflow_release.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts ├── settings.gradle.kts └── src │ └── main │ └── kotlin │ └── buildsrc │ ├── convention │ ├── base.gradle.kts │ ├── dokkatoo.gradle.kts │ ├── kotlin-jvm.gradle.kts │ └── maven-publish.gradle.kts │ └── ext │ ├── KotkaPublishingSettings.kt │ ├── gradle.kt │ └── publishing.kt ├── docs ├── build.gradle.kts ├── images │ └── logo-icon.svg └── styles │ └── logo-styles.css ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── jitpack.yml ├── modules ├── kotka-streams-extensions │ ├── build.gradle.kts │ ├── module.md │ └── src │ │ ├── main │ │ └── kotlin │ │ │ └── dev │ │ │ └── adamko │ │ │ └── kotka │ │ │ └── extensions │ │ │ ├── KeyValue.kt │ │ │ ├── QueryableStoreType.kt │ │ │ ├── materialized.kt │ │ │ ├── namedOperations.kt │ │ │ ├── processor │ │ │ └── recordExtensions.kt │ │ │ ├── serdes.kt │ │ │ ├── state │ │ │ └── keyValueStore.kt │ │ │ ├── streams │ │ │ ├── BranchedKStream.kt │ │ │ ├── KGroupedStream.kt │ │ │ ├── KStream.kt │ │ │ ├── KStreamTransform.kt │ │ │ └── topicNameExtractor.kt │ │ │ ├── streamsBuilder.kt │ │ │ └── tables │ │ │ └── KTable.kt │ │ └── test │ │ └── kotlin │ │ └── dev │ │ └── adamko │ │ └── kotka │ │ └── extensions │ │ ├── KeyValueTest.kt │ │ ├── SerdesTests.kt │ │ ├── StreamsBuilderTests.kt │ │ ├── processor │ │ └── RecordExtensionsTest.kt │ │ ├── streams │ │ ├── BranchedKStreamTest.kt │ │ └── KGroupedStreamTest.kt │ │ └── tables │ │ └── KTableExtensionsTests.kt ├── kotka-streams-framework │ ├── build.gradle.kts │ ├── module.md │ └── src │ │ └── main │ │ └── kotlin │ │ └── dev │ │ └── adamko │ │ └── kotka │ │ └── topicdata │ │ ├── GlobalKTableDefinition.kt │ │ ├── KeyValueSerdes.kt │ │ ├── TopicDefinition.kt │ │ └── TopicRecord.kt ├── kotka-streams-kotlinx-serialization │ ├── build.gradle.kts │ ├── module.md │ └── src │ │ ├── main │ │ └── kotlin │ │ │ └── dev │ │ │ └── adamko │ │ │ └── kotka │ │ │ └── kxs │ │ │ ├── KotkaJsonModule.kt │ │ │ ├── binaryFormatSerde.kt │ │ │ └── stringFormatSerde.kt │ │ └── test │ │ └── kotlin │ │ └── dev │ │ └── adamko │ │ └── kotka │ │ └── kxs │ │ ├── BinaryFormatSerdeTest.kt │ │ └── StringFormatSerdeTest.kt └── versions-platform │ └── build.gradle.kts └── settings.gradle.kts /.gitattributes: -------------------------------------------------------------------------------- 1 | text eol=lf 2 | 3 | # jvm sources 4 | *.kt text diff=java 5 | *.kts text diff=java 6 | 7 | 8 | # These are explicitly windows files and should use crlf 9 | *.bat text eol=crlf 10 | 11 | # These files are text and should be normalized (Convert crlf => lf) 12 | *.bash text eol=lf 13 | *.sh text eol=lf 14 | 15 | # These files are binary and should be left untouched 16 | # (binary is a macro for -text -diff) 17 | *.jar binary 18 | *.war binary 19 | 20 | # https://github.com/github/linguist/blob/v7.24.1/docs/overrides.md 21 | docs/** linguist-documentation 22 | -------------------------------------------------------------------------------- /.github/renovate.json5: -------------------------------------------------------------------------------- 1 | { 2 | $schema: "https://docs.renovatebot.com/renovate-schema.json", 3 | extends: [ 4 | "config:base" 5 | ], 6 | enabled: true, 7 | enabledManagers: [ 8 | "gradle", 9 | "gradle-wrapper", 10 | "github-actions", 11 | ], 12 | // Will auto-merge directly, without a PR, if tests pass - else, makes a PR. 13 | // Must add Renovate to 'Allow specified actors to bypass required pull requests' 14 | // in branch protection rule 15 | automergeType: "branch", 16 | platformAutomerge: true, 17 | ignoreTests: false, 18 | packageRules: [ 19 | { 20 | description: "auto-merge all but major releases", 21 | matchUpdateTypes: [ 22 | "minor", 23 | "patch", 24 | "pin", 25 | "digest", 26 | ], 27 | automerge: true, 28 | } 29 | ], 30 | timezone: "Etc/UTC", 31 | // loosely limit to Europe work hours, so we don't get pinged in the middle of the night 32 | schedule: [ 33 | "after 10am and before 6pm" 34 | ], 35 | automergeSchedule: [ 36 | "after 10am and before 6pm" 37 | ], 38 | stabilityDays: 14, 39 | // suppressNotifications: [ 40 | // "artifactErrors", 41 | // "branchAutomergeFailure", 42 | // "configErrorIssue", 43 | // "deprecationWarningIssues", 44 | // "lockFileErrors", 45 | // "onboardingClose", 46 | // "prEditedNotification", 47 | // "prIgnoreNotification", 48 | // ], 49 | prCreation: "status-success", 50 | semanticCommits: "disabled", 51 | ignorePaths: [] 52 | } 53 | -------------------------------------------------------------------------------- /.github/workflows/run_gradle_task.yml: -------------------------------------------------------------------------------- 1 | name: Gradle Task 2 | run-name: "Gradle Task ${{ inputs.gradle-task }} @ ${{ inputs.runs-on }}" 3 | 4 | # Reusable Workflow for running a Gradle task 5 | 6 | on: 7 | workflow_dispatch: 8 | inputs: 9 | gradle-task: 10 | description: "The Gradle task to run, including any flags" 11 | required: true 12 | type: string 13 | runs-on: 14 | description: "OS to run the task on" 15 | required: true 16 | type: string 17 | checkout-ref: 18 | description: "The branch, tag or SHA to checkout. See actions/checkout 'ref'." 19 | required: false 20 | type: string 21 | github-environment: 22 | description: "GitHub Environment name" 23 | required: false 24 | type: string 25 | github-environment-url: 26 | description: "GitHub Environment display URL" 27 | required: false 28 | type: string 29 | workflow_call: 30 | inputs: 31 | gradle-task: 32 | description: "The Gradle task to run, including any flags" 33 | required: true 34 | type: string 35 | runs-on: 36 | description: "OS to run the task on" 37 | required: true 38 | type: string 39 | checkout-ref: 40 | description: "The branch, tag or SHA to checkout. See actions/checkout 'ref'." 41 | required: false 42 | type: string 43 | github-environment: 44 | description: "GitHub Environment name" 45 | required: false 46 | type: string 47 | github-environment-url: 48 | description: "GitHub Environment display URL" 49 | required: false 50 | type: string 51 | 52 | 53 | concurrency: 54 | # note: the Workflow inputs are also included in the concurrency group 55 | group: "Gradle Task: ${{ github.workflow }} ${{ join(inputs.*) }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" 56 | cancel-in-progress: true 57 | 58 | 59 | permissions: 60 | contents: read 61 | checks: write # required by mikepenz/action-junit-report 62 | packages: write 63 | 64 | 65 | jobs: 66 | 67 | run-task: 68 | runs-on: ${{ inputs.runs-on }} 69 | name: "./gradlew ${{ inputs.gradle-task}} @ ${{ inputs.runs-on }}" 70 | timeout-minutes: 60 71 | environment: 72 | name: ${{ inputs.github-environment }} 73 | url: ${{ inputs.github-environment-url }} 74 | steps: 75 | 76 | ### Gradle task ### 77 | 78 | - name: Checkout the repo 79 | uses: actions/checkout@v4 80 | with: 81 | ref: ${{ inputs.checkout-ref || github.ref }} 82 | 83 | - name: Validate Gradle Wrapper 84 | uses: gradle/wrapper-validation-action@v1 85 | 86 | - name: Setup JDK 87 | uses: actions/setup-java@v4 88 | with: 89 | distribution: temurin 90 | java-version: 11 91 | 92 | - uses: gradle/gradle-build-action@v2 93 | with: 94 | gradle-home-cache-cleanup: true 95 | arguments: ${{ inputs.gradle-task }} 96 | env: 97 | "ORG_GRADLE_PROJECT_signing.keyId": ${{ secrets.MAVEN_SONATYPE_SIGNING_KEY_ID }} 98 | "ORG_GRADLE_PROJECT_signing.key": ${{ secrets.MAVEN_SONATYPE_SIGNING_KEY }} 99 | "ORG_GRADLE_PROJECT_signing.password": ${{ secrets.MAVEN_SONATYPE_SIGNING_PASSWORD }} 100 | ORG_GRADLE_PROJECT_sonatypeRepositoryUsername: ${{ secrets.MAVEN_SONATYPE_USERNAME }} 101 | ORG_GRADLE_PROJECT_sonatypeRepositoryPassword: ${{ secrets.MAVEN_SONATYPE_PASSWORD }} 102 | 103 | ORG_GRADLE_PROJECT_gitHubPackagesUsername: ${{ github.actor }} 104 | ORG_GRADLE_PROJECT_gitHubPackagesPassword: ${{ secrets.GITHUB_TOKEN }} 105 | 106 | - name: Upload build reports 107 | if: failure() 108 | uses: actions/upload-artifact@v4 109 | with: 110 | name: build-report-${{ runner.os }}${{ github.action }} 111 | path: | 112 | **/build/reports/ 113 | **/*.hprof 114 | **/*.log 115 | if-no-files-found: ignore 116 | 117 | - name: Publish Test Reports 118 | uses: mikepenz/action-junit-report@v4 119 | if: always() 120 | with: 121 | report_paths: | 122 | **/build/test-results/**/TEST-*.xml 123 | require_tests: false 124 | -------------------------------------------------------------------------------- /.github/workflows/run_publish_maven.yml: -------------------------------------------------------------------------------- 1 | name: Publish Maven 2 | 3 | 4 | on: 5 | workflow_dispatch: 6 | inputs: 7 | checkout-ref: 8 | description: "The branch, tag or SHA to checkout. See actions/checkout 'ref'." 9 | required: false 10 | type: string 11 | workflow_call: 12 | inputs: 13 | checkout-ref: 14 | description: "The branch, tag or SHA to checkout. See actions/checkout 'ref'." 15 | required: false 16 | type: string 17 | 18 | 19 | concurrency: 20 | group: "Publish Maven: ${{ github.workflow }}" 21 | cancel-in-progress: false 22 | 23 | 24 | permissions: 25 | contents: write 26 | packages: write 27 | checks: write 28 | 29 | 30 | jobs: 31 | 32 | sonatype-release: 33 | permissions: 34 | contents: read 35 | packages: write 36 | checks: write 37 | uses: ./.github/workflows/run_gradle_task.yml 38 | secrets: inherit 39 | with: 40 | runs-on: ubuntu-latest 41 | gradle-task: >- 42 | publishAllPublicationsToSonatypeRepository 43 | --stacktrace 44 | --no-configuration-cache 45 | --no-parallel 46 | github-environment: sonatype-publish 47 | github-environment-url: https://s01.oss.sonatype.org/ 48 | checkout-ref: ${{ inputs.checkout-ref }} 49 | 50 | 51 | github-packages-release: 52 | permissions: 53 | contents: read 54 | packages: write 55 | checks: write 56 | uses: ./.github/workflows/run_gradle_task.yml 57 | secrets: inherit 58 | with: 59 | runs-on: ubuntu-latest 60 | gradle-task: >- 61 | publishAllPublicationsToGitHubPackagesRepository 62 | --stacktrace 63 | --no-configuration-cache 64 | --no-parallel 65 | checkout-ref: ${{ inputs.checkout-ref }} 66 | -------------------------------------------------------------------------------- /.github/workflows/run_publish_site.yml: -------------------------------------------------------------------------------- 1 | name: Publish Site 2 | 3 | 4 | on: 5 | workflow_dispatch: 6 | inputs: 7 | checkout-ref: 8 | description: "The branch, tag or SHA to checkout. See actions/checkout 'ref'." 9 | required: false 10 | type: string 11 | workflow_call: 12 | inputs: 13 | checkout-ref: 14 | description: "The branch, tag or SHA to checkout. See actions/checkout 'ref'." 15 | required: false 16 | type: string 17 | 18 | 19 | concurrency: 20 | group: "Publish Site: ${{ github.workflow }}" 21 | cancel-in-progress: true 22 | 23 | 24 | jobs: 25 | 26 | build: 27 | runs-on: ubuntu-latest 28 | steps: 29 | - name: Checkout the repo 30 | uses: actions/checkout@v4 31 | with: 32 | ref: ${{ inputs.checkout-ref || github.ref }} 33 | 34 | - name: Validate Gradle Wrapper 35 | uses: gradle/wrapper-validation-action@v1 36 | 37 | - name: Setup JDK 38 | uses: actions/setup-java@v4 39 | with: 40 | distribution: temurin 41 | java-version: 11 42 | 43 | - uses: gradle/gradle-build-action@v2 44 | with: 45 | gradle-home-cache-cleanup: true 46 | arguments: | 47 | :docs:dokkatooGenerate 48 | 49 | - uses: actions/upload-pages-artifact@v3 50 | with: 51 | path: ./docs/build/dokka/html 52 | 53 | deploy: 54 | needs: build 55 | runs-on: ubuntu-latest 56 | permissions: 57 | pages: write # to deploy to Pages 58 | id-token: write # to verify the deployment originates from an appropriate source 59 | environment: 60 | name: github-pages 61 | url: ${{ steps.deployment.outputs.page_url }} 62 | steps: 63 | - name: Deploy to GitHub Pages 64 | id: deployment 65 | uses: actions/deploy-pages@v4 66 | -------------------------------------------------------------------------------- /.github/workflows/run_tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | 4 | on: 5 | workflow_dispatch: 6 | inputs: 7 | checkout-ref: 8 | description: "The branch, tag or SHA to checkout. See actions/checkout 'ref'." 9 | required: false 10 | type: string 11 | workflow_call: 12 | inputs: 13 | checkout-ref: 14 | description: "The branch, tag or SHA to checkout. See actions/checkout 'ref'." 15 | required: false 16 | type: string 17 | 18 | 19 | concurrency: 20 | group: "Tests: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" 21 | cancel-in-progress: true 22 | 23 | 24 | permissions: 25 | contents: read 26 | checks: write # required by mikepenz/action-junit-report 27 | 28 | 29 | jobs: 30 | 31 | gradle-check: 32 | strategy: 33 | matrix: 34 | os: [ ubuntu-latest, macos-latest, windows-latest ] 35 | fail-fast: false 36 | uses: ./.github/workflows/run_gradle_task.yml 37 | with: 38 | runs-on: ${{ matrix.os }} 39 | gradle-task: check --stacktrace 40 | checkout-ref: ${{ inputs.checkout-ref }} 41 | 42 | build-site: 43 | # verify that the site can be built, but don't deploy it 44 | uses: ./.github/workflows/run_gradle_task.yml 45 | with: 46 | runs-on: ubuntu-latest 47 | gradle-task: :docs:dokkatooGenerate 48 | checkout-ref: ${{ inputs.checkout-ref }} 49 | -------------------------------------------------------------------------------- /.github/workflows/workflow_pull_request.yml: -------------------------------------------------------------------------------- 1 | name: Pull Requests 2 | 3 | 4 | on: 5 | workflow_dispatch: 6 | pull_request: 7 | merge_group: 8 | push: 9 | branches: 10 | - "renovate/**" 11 | 12 | 13 | concurrency: 14 | group: "Pull Requests: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" 15 | cancel-in-progress: true 16 | 17 | 18 | jobs: 19 | 20 | tests: 21 | uses: ./.github/workflows/run_tests.yml 22 | permissions: 23 | contents: read 24 | checks: write 25 | -------------------------------------------------------------------------------- /.github/workflows/workflow_release.yml: -------------------------------------------------------------------------------- 1 | name: Releases 2 | 3 | 4 | on: 5 | workflow_dispatch: 6 | inputs: 7 | checkout-ref: 8 | description: "The branch, tag or SHA to checkout. See actions/checkout 'ref'." 9 | required: false 10 | type: string 11 | push: 12 | branches: [ main ] 13 | release: 14 | types: [ created ] 15 | 16 | 17 | concurrency: 18 | group: "Releases: ${{ github.workflow }} @ ${{ inputs.checkout-ref }} ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" 19 | cancel-in-progress: false 20 | 21 | 22 | jobs: 23 | 24 | tests: 25 | uses: ./.github/workflows/run_tests.yml 26 | permissions: 27 | checks: write 28 | contents: read 29 | with: 30 | checkout-ref: ${{ inputs.checkout-ref }} 31 | 32 | publish-maven: 33 | needs: tests 34 | # only publish when manually triggered, or it's the main branch, or it's for a release 35 | if: inputs.checkout-ref || github.ref == 'refs/heads/main' || (github.event_name == 'release' && github.event.action == 'created') 36 | uses: ./.github/workflows/run_publish_maven.yml 37 | secrets: inherit 38 | permissions: 39 | checks: write 40 | contents: write 41 | packages: write 42 | with: 43 | checkout-ref: ${{ inputs.checkout-ref }} 44 | 45 | publish-site: 46 | needs: tests 47 | # only publish when manually triggered, or it's for a release 48 | if: inputs.checkout-ref || (github.event_name == 'release' && github.event.action == 'created') 49 | uses: ./.github/workflows/run_publish_site.yml 50 | permissions: 51 | checks: write 52 | contents: read 53 | id-token: write # to verify the deployment originates from an appropriate source 54 | packages: write 55 | pages: write # to deploy to Pages 56 | with: 57 | checkout-ref: ${{ inputs.checkout-ref }} 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | ### Intellij ### 3 | .idea/** 4 | *.iml 5 | *.ipr 6 | *.iws 7 | out/ 8 | 9 | ### Eclipse ### 10 | .metadata 11 | bin/ 12 | tmp/ 13 | *.tmp 14 | *.bak 15 | *.swp 16 | *~.nib 17 | local.properties 18 | .settings/ 19 | .loadpath 20 | .recommenders 21 | 22 | # External tool builders 23 | .externalToolBuilders/ 24 | 25 | # Locally stored "Eclipse launch configurations" 26 | *.launch 27 | 28 | # PyDev specific (Python IDE for Eclipse) 29 | *.pydevproject 30 | 31 | # CDT-specific (C/C++ Development Tooling) 32 | .cproject 33 | 34 | # CDT- autotools 35 | .autotools 36 | 37 | # Java annotation processor (APT) 38 | .factorypath 39 | 40 | # PDT-specific (PHP Development Tools) 41 | .buildpath 42 | 43 | # sbteclipse plugin 44 | .target 45 | 46 | # Tern plugin 47 | .tern-project 48 | 49 | # TeXlipse plugin 50 | .texlipse 51 | 52 | # STS (Spring Tool Suite) 53 | .springBeans 54 | 55 | # Code Recommenders 56 | .recommenders/ 57 | 58 | # Annotation Processing 59 | .apt_generated/ 60 | .apt_generated_test/ 61 | 62 | # Scala IDE specific (Scala & Java development for Eclipse) 63 | .cache-main 64 | .scala_dependencies 65 | .worksheet 66 | 67 | ### Kotlin ### 68 | # Compiled class file 69 | *.class 70 | 71 | # Log file 72 | *.log 73 | 74 | # BlueJ files 75 | *.ctxt 76 | 77 | # Mobile Tools for Java (J2ME) 78 | .mtj.tmp/ 79 | 80 | # Package Files # 81 | *.jar 82 | *.war 83 | *.nar 84 | *.ear 85 | *.zip 86 | *.tar.gz 87 | *.rar 88 | 89 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 90 | hs_err_pid* 91 | replay_pid* 92 | 93 | ### Linux ### 94 | *~ 95 | 96 | # temporary files which can be created if a process still has a handle open of a deleted file 97 | .fuse_hidden* 98 | 99 | # KDE directory preferences 100 | .directory 101 | 102 | # Linux trash folder which might appear on any partition or disk 103 | .Trash-* 104 | 105 | # .nfs files are created when an open file is removed but is still being accessed 106 | .nfs* 107 | 108 | ### macOS ### 109 | # General 110 | .DS_Store 111 | .AppleDouble 112 | .LSOverride 113 | 114 | # Icon must end with two \r 115 | Icon 116 | 117 | # Thumbnails 118 | ._* 119 | 120 | # Files that might appear in the root of a volume 121 | .DocumentRevisions-V100 122 | .fseventsd 123 | .Spotlight-V100 124 | .TemporaryItems 125 | .Trashes 126 | .VolumeIcon.icns 127 | .com.apple.timemachine.donotpresent 128 | 129 | # Directories potentially created on remote AFP share 130 | .AppleDB 131 | .AppleDesktop 132 | Network Trash Folder 133 | Temporary Items 134 | .apdisk 135 | 136 | ### Windows ### 137 | # Windows thumbnail cache files 138 | Thumbs.db 139 | Thumbs.db:encryptable 140 | ehthumbs.db 141 | ehthumbs_vista.db 142 | 143 | # Dump file 144 | *.stackdump 145 | 146 | # Folder config file 147 | [Dd]esktop.ini 148 | 149 | # Recycle Bin used on file shares 150 | $RECYCLE.BIN/ 151 | 152 | # Windows Installer files 153 | *.cab 154 | *.msi 155 | *.msix 156 | *.msm 157 | *.msp 158 | 159 | # Windows shortcuts 160 | *.lnk 161 | 162 | ### Gradle ### 163 | .gradle 164 | build/ 165 | 166 | # Ignore Gradle GUI config 167 | gradle-app.setting 168 | 169 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 170 | !gradle-wrapper.jar 171 | 172 | # Cache of project 173 | .gradletasknamecache 174 | 175 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 176 | # gradle/wrapper/gradle-wrapper.properties 177 | 178 | ### Gradle Patch ### 179 | **/build/ 180 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![GitHub license](https://img.shields.io/github/license/adamko-dev/kotka-streams?style=flat-square)](https://github.com/adamko-dev/kotka-streams/blob/main/LICENSE) 2 | [![](https://jitpack.io/v/adamko-dev/kotka-streams.svg?style=flat-square)](https://jitpack.io/#adamko-dev/kotka-streams) 3 | [![Maven Central](https://img.shields.io/maven-central/v/dev.adamko.kotka/kotka-streams?color=%234c1&style=flat-square)](https://search.maven.org/search?q=g:dev.adamko.kotka) 4 | [![Maven Central Snapshots](https://img.shields.io/maven-metadata/v?label=snapshots&metadataUrl=https%3A%2F%2Fs01.oss.sonatype.org%2Fcontent%2Frepositories%2Fsnapshots%2Fdev%2Fadamko%2Fkotka%2Fkotka-streams%2Fmaven-metadata.xml&style=flat-square&color=%234ff)](https://s01.oss.sonatype.org/content/repositories/snapshots/dev/adamko/kotka/) 5 | 6 | # Kotka Streams - Kotlin for Kafka Streams 7 | 8 | Using [Kotka](https://github.com/adamko-dev/kotka-streams) means a more pleasant experience while 9 | using [Kafka Streams](https://kafka.apache.org/documentation/streams/). 10 | 11 | 12 | ## Quickstart 13 | 14 | Add a dependency on `kotka-streams-extensions` for the basics. 15 | 16 | ```kotlin 17 | // build.gradle.kts 18 | repositories { 19 | mavenCentral() 20 | } 21 | 22 | dependencies { 23 | implementation("dev.adamko.kotka:kotka-streams-extensions:$kotkaVersion") 24 | } 25 | ``` 26 | 27 | ## Modules 28 | 29 | There are three modules. Add a dependency on `com.github.adamko-dev:kotka-streams` to get them all 30 | at once 31 | 32 | ```kotlin 33 | dependencies { 34 | implementation("dev.adamko.kotka:kotka-streams:$kotkaVersion") 35 | } 36 | ``` 37 | 38 | ### `kotka-streams-extensions` 39 | 40 | Contains the basic extension functions to make Kafka Streams more Kotlin-esque. 41 | 42 | ```kotlin 43 | implementation("dev.adamko.kotka:kotka-streams-extensions:$kotkaVersion") 44 | ``` 45 | 46 | ```kotlin 47 | import dev.adamko.kotka.extensions.tables.* 48 | import dev.adamko.kotka.extensions.streams.* 49 | import dev.adamko.kotka.extensions.* 50 | 51 | data class MusicalBand( 52 | val name: String, 53 | val memberNames: List, 54 | ) 55 | 56 | builder.stream("musical-bands") 57 | .flatMap("band-member-names-to-band-name") { _: String, band: MusicalBand -> 58 | band.memberNames.map { memberName -> memberName to band.name } 59 | } 60 | .groupByKey(groupedAs("map-of-band-member-to-band-names")) 61 | ``` 62 | 63 | ### `kotka-streams-framework` 64 | 65 | A light framework for structuring topics and records. 66 | 67 | ```kotlin 68 | implementation("dev.adamko.kotka:kotka-streams-framework:$kotkaVersion") 69 | ``` 70 | 71 | Use `TopicRecord` to standardise the data on each topic. Records can now easily be converted from 72 | one type, to another. 73 | 74 | ```kotlin 75 | import dev.adamko.kotka.extensions.tables.* 76 | import dev.adamko.kotka.extensions.streams.* 77 | import dev.adamko.kotka.extensions.* 78 | import dev.adamko.kotka.topicdata.* 79 | 80 | data class Animal( 81 | val id: Long, 82 | val name: String, 83 | ) : TopicRecord { 84 | override val topicKey: Long by ::id 85 | } 86 | 87 | data class Pet( 88 | val id: Long, 89 | val name: String, 90 | ) : TopicRecord { 91 | override val topicKey: Long by ::id 92 | } 93 | 94 | val petUpdates = builder.stream("animals") 95 | .mapTopicRecords("convert-animals-to-pets") { _, animal -> 96 | Pet(animal.id, animal.name) 97 | } 98 | ``` 99 | 100 | Use `KeyValueSerdes` to define both the key and value serdes for a topic. 101 | A `TopicDefinition` ties both of these together. 102 | 103 | ```kotlin 104 | /** All [Pet] updates */ 105 | object PetUpdatesTopic : TopicDefinition { 106 | override val topicName = "pet-updates" 107 | override val serdes = KeyValueSerdes(Serdes.Long(), PetSerde()) 108 | } 109 | 110 | petUpdates 111 | .to( 112 | PetUpdatesTopic.topicName, 113 | PetUpdatesTopic.serdes.producer("send-pet-updates-to-pet-update-topic") 114 | ) 115 | ``` 116 | 117 | ### `kotka-streams-kotlinx-serialization` 118 | 119 | Use [Kotlinx Serialization](https://github.com/Kotlin/kotlinx.serialization/) for topic key/value 120 | serdes. 121 | 122 | ```kotlin 123 | implementation("dev.adamko.kotka:kotka-streams-kotlinx-serialization:$kotkaVersion") 124 | ``` 125 | 126 | ```kotlin 127 | import dev.adamko.kotka.extensions.tables.* 128 | import dev.adamko.kotka.extensions.streams.* 129 | import dev.adamko.kotka.extensions.* 130 | import dev.adamko.kotka.topicdata.* 131 | import dev.adamko.kotka.kxs.* 132 | 133 | val jsonMapper = Json {} 134 | 135 | @Serializable 136 | data class Sku( 137 | val sku: String 138 | ) 139 | 140 | @Serializable 141 | data class ShopItem( 142 | val id: Sku, 143 | val name: String, 144 | ) : TopicRecord { 145 | override val topicKey: Sku by ::id 146 | } 147 | 148 | object ShopItemTopic : TopicDefinition { 149 | override val topicName = "shop-item-updates" 150 | override val serdes = KeyValueSerdes.kxsJson(jsonMapper) 151 | } 152 | ``` 153 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | import buildsrc.ext.excludeGeneratedGradleDsl 2 | import buildsrc.ext.initIdeProjectLogo 3 | 4 | plugins { 5 | buildsrc.convention.`kotlin-jvm` 6 | buildsrc.convention.`maven-publish` 7 | `project-report` 8 | // `build-dashboard` // incompatible with Gradle CC 9 | idea 10 | } 11 | 12 | group = "dev.adamko.kotka" 13 | version = object { 14 | private val gitVersion = project.gitVersion 15 | override fun toString(): String = gitVersion.get() 16 | } 17 | 18 | dependencies { 19 | implementation(platform(projects.modules.versionsPlatform)) 20 | 21 | api(projects.modules.kotkaStreamsExtensions) 22 | api(projects.modules.kotkaStreamsFramework) 23 | api(projects.modules.kotkaStreamsKotlinxSerialization) 24 | } 25 | 26 | 27 | kotkaPublishing { 28 | mavenPomSubprojectName.set("Kotlin for Kafka Streams") 29 | mavenPomDescription.set("Using Kotka means a more pleasant experience while using Kafka Streams") 30 | } 31 | 32 | idea { 33 | module { 34 | excludeGeneratedGradleDsl(layout) 35 | excludeDirs = excludeDirs + layout.files( 36 | ".idea", 37 | "gradle/wrapper", 38 | ) 39 | } 40 | } 41 | 42 | initIdeProjectLogo("docs/images/logo-icon.svg") 43 | 44 | val projectVersion by tasks.registering { 45 | description = "prints the project version" 46 | group = "help" 47 | val version = providers.provider { project.version } 48 | inputs.property("version", version) 49 | outputs.cacheIf("logging task, it should always run") { false } 50 | doLast { 51 | logger.quiet("${version.orNull}") 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | dependencies { 6 | implementation(libs.gradlePlugin.kotlin) 7 | implementation(libs.gradlePlugin.kotlinxSerialization) 8 | 9 | implementation(libs.gradlePlugin.dokkatoo) 10 | 11 | // https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 12 | implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) 13 | } 14 | 15 | kotlin { 16 | jvmToolchain(11) 17 | } 18 | -------------------------------------------------------------------------------- /buildSrc/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "buildSrc" 2 | 3 | pluginManagement { 4 | repositories { 5 | mavenCentral() 6 | gradlePluginPortal() 7 | } 8 | } 9 | 10 | @Suppress("UnstableApiUsage") 11 | dependencyResolutionManagement { 12 | repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) 13 | 14 | repositories { 15 | gradlePluginPortal() 16 | mavenCentral() 17 | } 18 | 19 | versionCatalogs { 20 | create("libs") { 21 | from(files("../gradle/libs.versions.toml")) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/buildsrc/convention/base.gradle.kts: -------------------------------------------------------------------------------- 1 | package buildsrc.convention 2 | 3 | import java.time.Duration 4 | import org.gradle.api.tasks.testing.logging.TestLogEvent 5 | 6 | plugins { 7 | base 8 | } 9 | 10 | if (project != rootProject) { 11 | project.group = rootProject.group 12 | project.version = rootProject.version 13 | } 14 | 15 | tasks.withType().configureEach { 16 | // https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives 17 | isPreserveFileTimestamps = false 18 | isReproducibleFileOrder = true 19 | } 20 | 21 | tasks.withType().configureEach { 22 | timeout.convention(Duration.ofMinutes(10)) 23 | 24 | testLogging { 25 | // don't log console output - it's too noisy 26 | showCauses = false 27 | showExceptions = false 28 | showStackTraces = false 29 | showStandardStreams = false 30 | events( 31 | // only log test outcomes 32 | TestLogEvent.PASSED, 33 | TestLogEvent.FAILED, 34 | TestLogEvent.SKIPPED, 35 | // TestLogEvent.STARTED, 36 | // TestLogEvent.STANDARD_ERROR, 37 | // TestLogEvent.STANDARD_OUT, 38 | ) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/buildsrc/convention/dokkatoo.gradle.kts: -------------------------------------------------------------------------------- 1 | package buildsrc.convention 2 | 3 | import buildsrc.ext.libs 4 | 5 | plugins { 6 | id("buildsrc.convention.base") 7 | id("dev.adamko.dokkatoo-html") 8 | } 9 | 10 | val kafkaBaseVersion = libs.versions.kafka.map { v -> 11 | val (major, minor) = v.split(".") 12 | "${major}${minor}" 13 | } 14 | 15 | val kafkaJavadocUrl = kafkaBaseVersion.map { v -> "https://kafka.apache.org/${v}/javadoc/" } 16 | val kafkaPackageListUrl = kafkaJavadocUrl.map { "$it/element-list" } 17 | 18 | 19 | dokkatoo { 20 | dokkatooSourceSets.configureEach { 21 | externalDocumentationLinks.create("kafka-streams") { 22 | enabled.convention(true) 23 | url(kafkaJavadocUrl) 24 | packageListUrl(kafkaPackageListUrl) 25 | } 26 | 27 | sourceLink { 28 | localDirectory.set(file("src/main/kotlin")) 29 | val relativeProjectPath = projectDir.relativeToOrNull(rootDir)?.invariantSeparatorsPath ?: "" 30 | remoteUrl("https://github.com/adamko-dev/kotka-streams/tree/main/$relativeProjectPath/src/main/kotlin") 31 | } 32 | } 33 | } 34 | 35 | tasks.dokkatooGeneratePublicationHtml { 36 | doLast { 37 | outputDirectory.get().asFile.walk() 38 | .filter { it.isFile && it.extension == "html" } 39 | .forEach { file -> 40 | file.writeText( 41 | file.readText() 42 | .replace( 43 | """""", 44 | """""", 45 | ) 46 | .replace( 47 | """ 48 |