This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait TreeSeq[+A] { | |
lazy val size: Int = this match { | |
case Leaf(_) => 1 | |
case Branch(l, r) => (l.size + r.size) | |
} | |
def +[A1 >: A](a1: A1): TreeSeq[A1] = TreeSeq(a1) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name := "zio-kafka-test" | |
version := "0.1" | |
scalaVersion := "2.13.3" | |
libraryDependencies += "dev.zio" %% "zio-kafka" % "0.12.0" | |
libraryDependencies += "dev.zio" %% "zio-streams" % "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Test { | |
import zio._ | |
import zio.duration._ | |
import zio.kafka.consumer._ | |
val settings: ConsumerSettings = | |
ConsumerSettings(List("localhost:9092")) | |
.withGroupId("group") | |
.withClientId("client") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zio._ | |
import zio.console._ | |
import zio.kafka.consumer._ | |
import zio.kafka.serde._ | |
val subscription: Subscription = Subscription.topics("topic") | |
val readKafka: RIO[Console with Blocking with Clock, Unit] = | |
Consumer.consumeWith(settings, subscription, Serde.string, Serde.string) { | |
case (key, value) => | |
putStrLn(s"Received message ${key}: ${value}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Test { | |
import zio._ | |
import zio.duration._ | |
import zio.kafka.consumer._ | |
val settings: ConsumerSettings = | |
ConsumerSettings(List("localhost:9092")) | |
.withGroupId("group") | |
.withClientId("client") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Test { | |
import zio._ | |
import zio.duration._ | |
import zio.kafka.consumer._ | |
val settings: ConsumerSettings = | |
ConsumerSettings(List("localhost:9092")) | |
.withGroupId("group") | |
.withClientId("client") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node { | |
constructor(key, value, color, left = null, right = null) { | |
Object.assign(this, { key, value, color, left, right }); | |
} | |
async insert(key, value) { | |
const cmp = key < this.key ? "left" : "right"; | |
const child = this[cmp]; | |
const newChild = child === null ? new Node(key, value, true) : await child.insert(key, value); | |
return newChild.color && this.color ? this.fixup(newChild, cmp) : new Node(this.key, this.value, this.color, cmp === "left" ? newChild : this.left, cmp === "right" ? newChild : this.right); |
OlderNewer