Skip to content

Instantly share code, notes, and snippets.

Patryk Jażdżewski pjazdzewski1990

Block or report user

Report or block pjazdzewski1990

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View TickTackToeTyped.scala
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
<!DOCTYPE html>
<html>
<style>
.outer {
position: absolute;
z-index: 9;
background-color: #f1f1f1;
text-align: center;
border: 1px solid #d3d3d3;
View CommandHandler.scala
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
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
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
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
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
trait CalculatorService extends Service {
def calculate(fromValue: BigDecimal,
fromUnit: String,
toUnit: String
): ServiceCall[NotUsed, CalculatedValue]
def descriptor(): Descriptor =
named("calculatorservice")
.`with`(
View Descriptor.scala
def descriptor(): Descriptor =
named("calculatorservice")
.`with`(
restCall(
Method.GET,
"/api/calculator/exchange?fromValue&fromUnit&toUnit",
calculate _
)
)
View Calculate.scala
def calculate(fromValue: BigDecimal,
fromUnit: String,
toUnit: String): ServiceCall[NotUsed, CalculatedValue]
You can’t perform that action at this time.