This file contains hidden or 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 TheApp extends App { | |
EventProcessor("BR").process | |
} | |
trait ESClient { | |
def country: String | |
def settings: String = "settings-" + country | |
def client: String | |
} |
This file contains hidden or 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 java.net.URLDecoder | |
def parseUrlParameters(url: String) = { | |
url.split("&").map( v => { | |
val m = v.split("=", 2).map(s => URLDecoder.decode(s, "UTF-8")) | |
m(0) -> m(1) | |
}).toMap | |
} |
This file contains hidden or 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
package com.gvolpe.fs2queue | |
import fs2.{Stream, Task, async} | |
object FS2QueueBehavior extends App { | |
implicit val S = fs2.Strategy.fromFixedDaemonPool(2, "fs2-queue") | |
val p1 = for { | |
simpleQ <- Stream.eval(async.boundedQueue[Task, String](10)) |
This file contains hidden or 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 akka.actor.Actor | |
/** | |
* Simple [[TypedActor]] that gives any class implementing it the power to have typed messages making | |
* proper use of the compiler for type check exhaustiveness by just using a typed [[Function1]]. | |
* | |
* For convenience use this trait instead of using directly [[Actor]] unless you have a good reason. | |
* */ | |
trait TypedActor[A] extends Actor { | |
type TypedReceive = A => Unit |
This file contains hidden or 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
private def liftToPF[X <: Y, W, Y](f: Function[X, W])(implicit ct: ClassTag[X]): PartialFunction[Y, W] = | |
new PartialFunction[Y, W] { | |
override def isDefinedAt(x: Y): Boolean = ct.runtimeClass.isInstance(x) | |
override def apply(v1: Y): W = f(v1.asInstanceOf[X]) | |
} | |
sealed trait MyError | |
case class ErrorOne(msg: String) extends MyError | |
case class ErrorTwo(msg: String) extends MyError | |
case class ErrorThree(msg: String) extends MyError |
This file contains hidden or 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 cats.effect.IO | |
import cats.syntax.apply._ | |
import fs2.{Scheduler, Stream, StreamApp} | |
import fs2.StreamApp.ExitCode | |
import scala.concurrent.ExecutionContext.Implicits.global | |
object Streaming extends StreamApp[IO] { | |
override def stream(args: List[String], requestShutdown: IO[Unit]): fs2.Stream[IO, ExitCode] = |
This file contains hidden or 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 java.io.FileOutputStream | |
import cats.effect.ExitCase.{Canceled, Completed, Error} | |
import cats.effect._ | |
import cats.syntax.apply._ | |
import cats.syntax.functor._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.duration._ |
This file contains hidden or 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 java.util.concurrent.Future | |
import cats.effect.{Effect, Sync, Timer} | |
import cats.syntax.all._ | |
import fs2._ | |
import fs2.async.mutable.Signal | |
import scala.concurrent.ExecutionContext | |
import scala.concurrent.duration._ |
This file contains hidden or 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
package com.github.gvolpe.fs2rabbit.examples | |
import cats.effect.Effect | |
import com.github.gvolpe.fs2rabbit.config.QueueConfig | |
import com.github.gvolpe.fs2rabbit.interpreter.Fs2Rabbit | |
import com.github.gvolpe.fs2rabbit.json.Fs2JsonEncoder | |
import com.github.gvolpe.fs2rabbit.model._ | |
import com.github.gvolpe.fs2rabbit.typeclasses.StreamEval | |
import fs2.{Pipe, Stream} |
This file contains hidden or 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
type Arguments = Args[A] forSome { type A } | |
final class Args[A: SafeArgument](val underlying: Map[String, A]) | |
object Arguments { | |
def empty: ArgumentsAlt[String] = new ArgumentsAlt(Map.empty) | |
def apply[V: SafeArgument](kv: (String, V)*): ArgumentsAlt[V] = | |
new ArgumentsAlt(kv.toMap) | |
} |
OlderNewer