View TickTackToeTyped.scala
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
package io.scalac | |
import akka.actor.typed.{ActorRef, ActorSystem, Behavior} | |
import akka.actor.typed.scaladsl.{ActorContext, Behaviors} | |
import akka.actor.typed.scaladsl.Behaviors.Receive | |
import akka.util.Timeout | |
import scala.concurrent.duration._ | |
import scala.concurrent.Future | |
import scala.util.Random |
View skills.html
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
<!DOCTYPE html> | |
<html> | |
<style> | |
.outer { | |
position: absolute; | |
z-index: 9; | |
background-color: #f1f1f1; | |
text-align: center; | |
border: 1px solid #d3d3d3; | |
View CommandHandler.scala
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
builder.setCommandHandler( | |
classOf[SaveRatio], | |
asJavaBiFunction | |
[SaveRatio, CommandContext[NotUsed], Persist[_ <: ExchangeEvent]]( | |
(cmd: SaveRatio, ctx: CommandContext[NotUsed]) => { | |
ctx.thenPersist( | |
saveRatioToRatioChanged(cmd), | |
(t: ExchangeEvent) => ctx.reply(NotUsed) | |
) | |
} |
View Implicits.scala
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 Implicits { | |
implicit def requestToServiceCallWithCompletedFuture[Req, Resp] | |
(reqFunc: Req => Resp): ServiceCall[Req, Resp] = { | |
new ServiceCall[Req, Resp] { | |
override def invoke(request: Req): CompletionStage[Resp] = { | |
completedFuture(reqFunc(request)) | |
} | |
} | |
} |
View ExceptionSerializer.scala
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
class MicroserviceExceptionSerializer extends ExceptionSerializer { | |
override def serialize(exception: Throwable, | |
accept: java.util.Collection[MessageProtocol]) | |
: RawExceptionMessage = { | |
val mp = MessageProtocol.fromContentTypeHeader(Optional.empty()) | |
val defaultMessage = new RawExceptionMessage( | |
TransportErrorCode.InternalServerError, | |
mp, |
View BigDecimalSerializer.scala
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
lazy val BigDecimalSerializer: PathParamSerializer[BigDecimal] = | |
com.lightbend.lagom.javadsl.api.deser.PathParamSerializers.required( | |
"BigDecimal", | |
(pathValue: String) => BigDecimal(pathValue), | |
(v: BigDecimal) => v.toString | |
) |
View ExchangeRateService.scala
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
trait ExchangeRatesService extends Service { | |
def getExchangeRate(fromUnit: String, | |
toUnit: String | |
): ServiceCall[NotUsed, ExchangeRatio] | |
def setExchangeRate(fromUnit: String, | |
toUnit: String | |
): ServiceCall[Rate, NotUsed] |
View CalculatorService.scala
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
trait CalculatorService extends Service { | |
def calculate(fromValue: BigDecimal, | |
fromUnit: String, | |
toUnit: String | |
): ServiceCall[NotUsed, CalculatedValue] | |
def descriptor(): Descriptor = | |
named("calculatorservice") | |
.`with`( |
View Descriptor.scala
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 descriptor(): Descriptor = | |
named("calculatorservice") | |
.`with`( | |
restCall( | |
Method.GET, | |
"/api/calculator/exchange?fromValue&fromUnit&toUnit", | |
calculate _ | |
) | |
) |
View Calculate.scala
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 calculate(fromValue: BigDecimal, | |
fromUnit: String, | |
toUnit: String): ServiceCall[NotUsed, CalculatedValue] |
NewerOlder