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
{ | |
"openapi": "3.0.0", | |
"info": { | |
"version": "1.0.0", | |
"title": "Swagger Petstore", | |
"license": { | |
"name": "MIT" | |
} | |
}, | |
"servers": [ |
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 java.time.Instant | |
import akka.actor.ActorSystem | |
import akka.http.scaladsl.model._ | |
import akka.stream.ActorMaterializer | |
import cats.data.EitherT | |
import cats.implicits._ | |
import com.twilio.service.encoding.json.CirceJsonSupport | |
import com.twilio.service.http.ServiceHttpClient.{ HttpClient, HttpError, IgnoredEntity, ServiceClientError, ServiceClientFailure, ServiceClientResult } | |
import com.twilio.service.http.{ ServiceHttpClient, SingleRequestHttpClient } |
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
implicit class FooBar(val json: Json) extends AnyVal { | |
def omitNull: Json = json | |
.mapArray(_.map(_.omitNull)) | |
.mapObject(_ | |
.filter { case (_, v) => !v.isNull } | |
.mapValues(_.omitNull) | |
) | |
} |
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 TestRunner { | |
def delayedFlow[T](delay: FiniteDuration)(implicit scheduler: Scheduler, ec: ExecutionContext): Flow[T, T, _] = { | |
Flow[T].mapAsyncUnordered(Int.MaxValue) { out => | |
val promise = Promise[T] | |
scheduler.scheduleOnce(delay)(promise.success(out)) | |
promise.future | |
} | |
} | |
} |
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 akka.actor.ActorSystem | |
import akka.stream.scaladsl.{Flow, GraphDSL, Merge, Partition, RunnableGraph, Sink, Source} | |
import akka.stream.{ActorMaterializer, ClosedShape, OverflowStrategy} | |
object GraphApp extends App { | |
implicit val actorSystem: ActorSystem = ActorSystem(name = "prog-voice") | |
implicit val mt: ActorMaterializer = ActorMaterializer() | |
val graph = RunnableGraph.fromGraph(GraphDSL.create() { implicit builder ⇒ |
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
def splitErrorsFlow[L, R, M, M1, M2]( | |
routesSource: Source[Either[L, R], M], | |
leftSink: Sink[L, M1], | |
rightSink: Sink[R, M2] | |
)(implicit ec: ExecutionContext): RunnableGraph[(M, M1, M2)] = | |
RunnableGraph.fromGraph(GraphDSL.create(routesSource, leftSink, rightSink)((_, _, _)) { implicit b => (s, l, r) => | |
import GraphDSL.Implicits._ | |
val broadcast = b.add(Broadcast[Either[L, R]](2)) |
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 akka.actor.ActorSystem | |
import akka.http.scaladsl.Http | |
import akka.http.scaladsl.model.{HttpRequest, HttpResponse, Uri} | |
import akka.stream.ActorMaterializer | |
import akka.stream.scaladsl.{Sink, Source} | |
import scala.concurrent.{Await, Future} | |
import scala.concurrent.duration._ | |
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 scala.concurrent.duration._ | |
import scala.concurrent.ExecutionContext | |
import scala.concurrent.Future | |
import akka.pattern.after | |
import akka.actor.Scheduler | |
/** | |
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown, | |
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through | |
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure. |
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 akka.actor.ActorSystem | |
import akka.http.scaladsl.Http | |
import akka.http.scaladsl.model.{Uri, HttpRequest, HttpResponse} | |
import akka.stream.ActorMaterializer | |
import akka.stream.scaladsl.{Sink, Source} | |
import scala.concurrent.Future | |
/** | |
* Mock Akka HTTP Server, will handle requests which is provided with handle request |
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
//Requires scalaz core and shapeless | |
import akka.actor.Actor.Receive | |
import akka.actor._ | |
import shapeless.{Coproduct, :+:, CNil} | |
import scalaz.{Tag, @@} | |
object Test extends App { |
NewerOlder