|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <meta name="viewport" content="width=device-width, initial-scale=1" charset="UTF-8"> |
| 5 | + <title>kotlin-kafka</title> |
| 6 | + <link href="images/logo-icon.svg" rel="icon" type="image/svg"> |
| 7 | + <script>var pathToRoot = "";</script> |
| 8 | + <script>const storage = localStorage.getItem("dokka-dark-mode") |
| 9 | +const savedDarkMode = storage ? JSON.parse(storage) : false |
| 10 | +if(savedDarkMode === true){ |
| 11 | + document.getElementsByTagName("html")[0].classList.add("theme-dark") |
| 12 | +}</script> |
| 13 | +<script type="text/javascript" src="scripts/sourceset_dependencies.js" async="async"></script> |
| 14 | +<link href="styles/style.css" rel="Stylesheet"> |
| 15 | +<link href="styles/jetbrains-mono.css" rel="Stylesheet"> |
| 16 | +<link href="styles/main.css" rel="Stylesheet"> |
| 17 | +<link href="styles/prism.css" rel="Stylesheet"> |
| 18 | +<link href="styles/logo-styles.css" rel="Stylesheet"> |
| 19 | +<script type="text/javascript" src="scripts/clipboard.js" async="async"></script> |
| 20 | +<script type="text/javascript" src="scripts/navigation-loader.js" async="async"></script> |
| 21 | +<script type="text/javascript" src="scripts/platform-content-handler.js" async="async"></script> |
| 22 | +<script type="text/javascript" src="scripts/main.js" defer="defer"></script> |
| 23 | +<script type="text/javascript" src="scripts/prism.js" async="async"></script> |
| 24 | +</head> |
| 25 | +<body> |
| 26 | +<div class="navigation-wrapper" id="navigation-wrapper"> |
| 27 | + <div id="leftToggler"><span class="icon-toggler"></span></div> |
| 28 | + <div class="library-name"> |
| 29 | + <a href="index.html"> |
| 30 | + <span>kotlin-kafka</span> |
| 31 | + </a> |
| 32 | + </div> |
| 33 | + <div> |
| 34 | +0.1.1-SNAPSHOT </div> |
| 35 | + <div class="pull-right d-flex"> |
| 36 | + <button id="theme-toggle-button"><span id="theme-toggle"></span></button> |
| 37 | + <div id="searchBar"></div> |
| 38 | + </div> |
| 39 | +</div> |
| 40 | +<div id="container"> |
| 41 | + <div id="leftColumn"> |
| 42 | + <div id="sideMenu"></div> |
| 43 | + </div> |
| 44 | + <div id="main"> |
| 45 | +<div class="main-content" id="content" pageIds="kotlin-kafka::////PointingToDeclaration//769193423"> |
| 46 | + <div class="breadcrumbs"></div> |
| 47 | + <div class="cover "> |
| 48 | + <h1 class="cover"><span><span>kotlin-kafka</span></span></h1> |
| 49 | + <div class="platform-hinted UnderCoverText" data-platform-hinted="data-platform-hinted"><div class="content sourceset-depenent-content" data-active="" data-togglable=":dokkaHtml/main"><p class="paragraph"><a href="https://maven-badges.herokuapp.com/maven-central/io.github.nomisrev/kotlin-kafka"></a></p><!--- TEST_NAME ReadmeTest --><!--- TOC --><ul><li><p class="paragraph">#rationale</p></li><li><p class="paragraph">#goals</p></li><li><p class="paragraph">#adding-dependency</p></li><li><p class="paragraph">#example</p></li></ul><!--- END --><p class="paragraph">This project is still under development, andd started as a playground where I was playing around with Kafka in Kotlin and the Kafka SDK whilst reading the Kafka book Definite Guide from Confluent. https://www.confluent.io/resources/kafka-the-definitive-guide-v2/</p><h2 class=""> Rationale</h2><p class="paragraph">At the time of starting this repository I didn't find any bindings between Kafka SDK and Kotlin suspension. These operators should be implemented low-level, so they can guarantee correct cancellation support, and high optimised runtimes.</p><h2 class=""> Goals</h2><ul><li><p class="paragraph">Lean Core library built on top of Kotlin Std & KotlinX Coroutines (possible extensions with Arrow in additional module)</p></li><li><p class="paragraph">Extensions to easily operate over the Kafka SDK with KotlinX Coroutines and <code class="lang-kotlin">suspend</code>.</p></li><li><p class="paragraph">Flow based operators, so you can easily compose KotlinX Flow based Kafka programs</p></li><li><p class="paragraph">example for testing Kafka with Test Containers in Kotlin.</p></li></ul><h2 class=""> Adding Dependency</h2><p class="paragraph">Simply add the following dependency as <code class="lang-kotlin">implementation</code> in the <code class="lang-kotlin">build.gradle</code> dependencies` block.</p><div class="sample-container"><pre><code class="block lang-groovy" theme="idea">dependencies {<br> implementation("io.github.nomisrev:kotlin-kafka:0.1")<br>}</code></pre><span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div><h2 class=""> Example</h2><!--- INCLUDE |
| 50 | +import java.util.UUID |
| 51 | +import kotlinx.coroutines.Dispatchers.Default |
| 52 | +import kotlinx.coroutines.coroutineScope |
| 53 | +import kotlinx.coroutines.flow.asFlow |
| 54 | +import kotlinx.coroutines.flow.collect |
| 55 | +import kotlinx.coroutines.flow.map |
| 56 | +import kotlinx.coroutines.flow.take |
| 57 | +import kotlinx.coroutines.launch |
| 58 | +import org.apache.kafka.clients.admin.NewTopic |
| 59 | +import org.apache.kafka.clients.producer.ProducerRecord |
| 60 | +import org.apache.kafka.common.serialization.IntegerDeserializer |
| 61 | +import org.apache.kafka.common.serialization.IntegerSerializer |
| 62 | +import org.apache.kafka.common.serialization.StringDeserializer |
| 63 | +import org.apache.kafka.common.serialization.StringSerializer |
| 64 | +--><div class="sample-container"><pre><code class="block lang-kotlin" theme="idea"></code></pre><span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div><div class="block"></div></div></div> |
| 65 | + </div> |
| 66 | + <h2 class="">Packages</h2> |
| 67 | + <div class="table"><a data-name="-1022263899%2FPackages%2F769193423" anchor-label="com.github.nomisRev.kafka" id="-1022263899%2FPackages%2F769193423" data-filterable-set=":dokkaHtml/main"></a> |
| 68 | + <div class="table-row" data-filterable-current=":dokkaHtml/main" data-filterable-set=":dokkaHtml/main"> |
| 69 | + <div> |
| 70 | + <div class="main-subrow "> |
| 71 | + <div class=""><span class="inline-flex"> |
| 72 | + <div><a href="kotlin-kafka/com.github.nomisRev.kafka/index.html">com.github.nomisRev.kafka</a></div> |
| 73 | +<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="-1022263899%2FPackages%2F769193423"></span> |
| 74 | + <div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div> |
| 75 | + </span></span></div> |
| 76 | + <div class="pull-right"></div> |
| 77 | + </div> |
| 78 | + <div></div> |
| 79 | + </div> |
| 80 | + </div> |
| 81 | + </div> |
| 82 | +</div> |
| 83 | + <div class="footer"> |
| 84 | + <span class="go-to-top-icon"><a href="#content" id="go-to-top-link"></a></span><span>© 2022 Copyright</span><span |
| 85 | + class="pull-right"><span>Generated by </span><a |
| 86 | + href="https://github.com/Kotlin/dokka"><span>dokka</span><span class="padded-icon"></span></a></span> |
| 87 | + </div> |
| 88 | + </div> |
| 89 | +</div> |
| 90 | +</body> |
| 91 | +</html> |
0 commit comments