Skip to content

Instantly share code, notes, and snippets.

@WadeWaldron
WadeWaldron / ChunkIteratee.scala
Created February 21, 2017 15:22
Chunked Responses
package chunkedresponses
import akka.actor.ActorRef
import akka.util.Timeout
import akka.pattern.ask
import play.api.libs.iteratee.{Done, Step, Input, Iteratee}
import spray.http.HttpData
import scala.concurrent.duration._
@WadeWaldron
WadeWaldron / build.sbt
Created March 18, 2016 20:09
KafkaConsumers-ReactiveKafka-SBT
libraryDependencies ++= Seq("com.softwaremill.reactivekafka" %% "reactive-kafka-core" % "0.10.0")
@WadeWaldron
WadeWaldron / build.sbt
Created March 18, 2016 20:08
KafkaConsumers-Spark-SBT
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % "1.6.1",
"org.apache.spark" %% "spark-streaming" % "1.6.1",
"org.apache.spark" %% "spark-streaming-kafka" % "1.6.1"
)
@WadeWaldron
WadeWaldron / build.sbt
Created March 18, 2016 20:06
KafkaConsumers-Java-SBT
libraryDependencies ++= Seq("org.apache.kafka" % "kafka-clients" % "0.9.0.1")
@WadeWaldron
WadeWaldron / ReactiveKafka.scala
Last active March 18, 2016 19:30
KafkaConsumers-ReactiveKafka
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Source
import com.softwaremill.react.kafka.{ConsumerProperties, ReactiveKafka}
import org.apache.kafka.common.serialization.StringDeserializer
import scala.concurrent.duration._
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
@WadeWaldron
WadeWaldron / SparkClient.scala
Created March 18, 2016 19:05
KafkaConsumers-Spark
import kafka.serializer.StringDecoder
import org.apache.spark.streaming.kafka.KafkaUtils
import org.apache.spark.streaming.{Seconds, StreamingContext}
import org.apache.spark.{SparkConf, SparkContext}
val checkpointDir = "/tmp/sparkcheckpoints"
val sparkConfig = new SparkConf().setAppName("SparkDriver").setMaster("local[2]")
val sparkContext = new SparkContext(sparkConfig)
@WadeWaldron
WadeWaldron / JavaConsumer.scala
Last active March 18, 2016 19:04
KafkaConsumers-Java
import java.util.Properties
import org.apache.kafka.clients.consumer.KafkaConsumer
import collection.JavaConverters._
val pollingTimeoutInMS = 100
val props = new Properties()
props.put("bootstrap.servers", "localhost:9092")
props.put("group.id", "JavaConsumer")
@WadeWaldron
WadeWaldron / Succeeded.scala
Last active March 18, 2016 17:17
StatsDrivenDevelopment-6
def succeeded(name: String)
def failed(name: String)
@WadeWaldron
WadeWaldron / Timed.scala
Created March 18, 2016 17:16
StatsDrivenDevelopment-5
def timed[T](name: String)(f: => T):T
@WadeWaldron
WadeWaldron / Measured.scala
Created March 18, 2016 17:15
StatsDrivenDevelopment-4
def measured(name: String, value: Long)