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 Example { | |
| def process(implicit strat: Strategy): Sink[Task, List[Int]] = { ms => | |
| ms.evalMap { i => | |
| Task { | |
| println(s"In consumer length ${i.length}") | |
| Thread.sleep(200) | |
| } | |
| } | |
| } |
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 Example { | |
| def main(args: Array[String]): Unit = { | |
| implicit val strat = fs2.Strategy.fromCachedDaemonPool() | |
| val ms: Stream[Task, String] = Stream.eval { | |
| Task { | |
| println("Evaluating message stream") | |
| Thread.sleep(1000) |
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 Example { | |
| def messageStream(client: AmazonSQSAsyncClient, request: ReceiveMessageRequest)(implicit s: Strategy): Stream[Task, Message] = { | |
| Stream.repeatEval(AsyncSQS.getMessagesAsync(client, request)).flatMap { result => | |
| Stream.emits(result.getMessages.asScala) | |
| } | |
| } | |
| def batchPipe(n: Int): Pipe[Task, Message, List[Message]] = { messages => | |
| messages.vectorChunkN(n, true).map(_.toList) | |
| } |
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
| case class Gen[A](g: () => A) { | |
| /* | |
| * Evaluates a Gen, yielding a value | |
| */ | |
| def sample: A = { | |
| g() | |
| } | |
| /* |
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 argonaut._ | |
| import Argonaut._ | |
| import argonaut.CursorOpDownArray | |
| case class Job(name: String, salary: Option[Int]) | |
| case class Person(name: String, job: Job) | |
| object Person { |
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
| var sumAsync = function(a, b, callback) { | |
| sleep(1000) | |
| return callback(a + b); | |
| } |
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
| { | |
| "name":"water", | |
| "generation":{ | |
| "url":"http:\/\/pokeapi.co\/api\/v2\/generation\/1\/", | |
| "name":"generation-i" | |
| }, | |
| "damage_relations":{ | |
| "half_damage_from":[ | |
| { | |
| "url":"http:\/\/pokeapi.co\/api\/v2\/type\/9\/", |
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 Example { | |
| def main(args: Array[String]): Unit = { | |
| val messages: Stream[fs2.Task, Int] = Stream.constant[fs2.Task, Int](1).repeat | |
| val process: Pipe[fs2.Task, Int, String] = _.evalMap { m => | |
| FS2Helpers.task2fs2Task(scalaz.concurrent.Task.now(m.toString)) // now, oddly, if this is Task { ... } instead of now(..) it works fine | |
| } | |
| val pipeline = messages.through(process) | |
| pipeline.run.unsafeRun() | |
| } | |
| } |
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 Metrics { | |
| val MetricsPrefix = "http4s" | |
| val StatusTagPrefix = "status" | |
| val StatusInformation = 100 | |
| val StatusOk = 200 | |
| val StatusRedirection = 300 | |
| val StatusClientError = 400 | |
| val StatusServerError = 500 |