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 sttp.tapir.examples | |
import akka.actor.ActorSystem | |
import akka.http.scaladsl.Http | |
import akka.http.scaladsl.server.Route | |
import sttp.tapir._ | |
import sttp.tapir.json.circe._ | |
import io.circe.generic.auto._ | |
import sttp.tapir.generic.auto._ | |
import sttp.tapir.server.akkahttp.AkkaHttpServerOptions |
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
//> using scala 3.3.1 | |
//> using dep com.softwaremill.sttp.tapir::tapir-netty-server:1.8.0 | |
//> using dep com.softwaremill.sttp.tapir::tapir-swagger-ui-bundle:1.8.0 | |
//> using dep com.softwaremill.sttp.tapir::tapir-json-circe:1.8.0 | |
package com.softwaremill | |
import sttp.tapir.* | |
import DragonApi.* | |
import ResponseApi.* |
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.softwaremill | |
import sttp.model.StatusCode | |
import sttp.monad.MonadError | |
import sttp.monad.syntax._ | |
import sttp.tapir.AttributeKey | |
import sttp.tapir.server.interceptor.* | |
import sttp.tapir.server.interpreter.BodyListener | |
import sttp.tapir.server.model.ServerResponse | |
import sttp.tapir.server.ziohttp.{ZioHttpInterpreter, ZioHttpServerOptions} |
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
//> using dep "com.softwaremill.sttp.client3::zio:3.8.15" | |
//> using dep "com.softwaremill.sttp.client3::slf4j-backend:3.8.15" | |
//> using dep "ch.qos.logback:logback-classic:1.4.7" | |
import org.slf4j.LoggerFactory | |
import sttp.client3.httpclient.zio.HttpClientZioBackend | |
import sttp.client3._ | |
import sttp.client3.logging.slf4j.Slf4jLoggingBackend | |
import sttp.client3.logging.LogLevel | |
import sttp.capabilities.WebSockets |
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
it should "succeed when it finishes shortly before the timeout" in { | |
// given | |
val slowService = new SlowService(responseTimes = List(2800.millis)) | |
val service = new TimeoutService(slowService) // 3s | |
// when | |
val result = service.run().unsafeToFuture() | |
ec.tick(TimeoutService.DefaultTimeout) // 3s forward in time! | |
// then |
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 MsgMetadata(offset: query.Offset, persistenceId: String, seqNum: Long) | |
trait EventsJournalOffsetDao { | |
def offsetFor(projection: ProjectionId): Future[Option[query.Offset]] | |
def saveOffset(projection: ProjectionId, currentOffset: query.Offset): Future[Unit] | |
} | |
class EventsStreamFactory( | |
config: EventsStreamConfig, | |
val projectionId: ProjectionId, |
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 io.circe.semiauto._ | |
import io.circe.syntax._ | |
final case class Address(street: String, zipCode: String, city: String) | |
object Address { | |
implicit val addressEcncoder: Encoder[Address] = deriveEncoder[Address] | |
implicit val addressDecoder: Decoder[Address] = deriveDecoder[Address] | |
} |
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 AroundDirectives { | |
val timeoutResponse = HttpResponse(StatusCodes.NetworkReadTimeout, entity = "Unable to serve response within time limit.") | |
def aroundRequest(onRequest: HttpRequest => Try[RouteResult] => Unit)(implicit ec: ExecutionContext): Directive0 = { | |
extractRequestContext.flatMap { ctx => | |
{ | |
val onDone = onRequest(ctx.request) | |
mapInnerRoute { inner => | |
withRequestTimeoutResponse( |
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 akka.kafka.scaladsl | |
import java.util.concurrent.TimeUnit | |
import java.util.{Properties, UUID} | |
import akka.actor.ActorSystem | |
import akka.kafka.{ConsumerSettings, ProducerSettings} | |
import akka.stream.ActorMaterializer | |
import akka.stream.scaladsl.Sink | |
import akka.testkit.TestKit |
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.softwaremill.react.kafka; | |
import org.apache.kafka.clients.consumer.ConsumerRecords; | |
import org.apache.kafka.clients.consumer.KafkaConsumer; | |
import org.apache.kafka.clients.producer.KafkaProducer; | |
import org.apache.kafka.clients.producer.ProducerRecord; | |
import java.util.Arrays; | |
import java.util.Properties; | |
import java.util.UUID; |
NewerOlder