Skip to content

Instantly share code, notes, and snippets.

View pawelkaczor's full-sized avatar
🏠
Working from home

Paweł Kaczor pawelkaczor

🏠
Working from home
View GitHub Profile
@pawelkaczor
pawelkaczor / scala_README.md
Created February 20, 2021 10:20
Fast and Furious

Fast and Furious - franchise

I'm sorry, but I provided only simple packages as entry points for service implementations. The packages represent separate services. The identification of possible services and the multi-tenancy (franchises) are the only interesting issues that I could think of based on the provided task description.

Unfortunately I find the challenge confusing as it mixes different goals and "levels". I can not design and solve a problem which is not described more precisely. It all depends on the concrete requirements. Depending on the requirements, the result architecture/design can be completely different. I leave all the simple tasks that do not involve (non-trivial) problem solving.

@pawelkaczor
pawelkaczor / ConfigExtensions.scala
Created September 27, 2017 07:19
Extension methods to Typesafe Config to support Docker Swarm secrets
package com.typesafe.config.impl
import com.typesafe.config.ConfigFactory.parseMap
import com.typesafe.config.{Config, ConfigFactory}
import scala.collection.JavaConverters._
import scala.io.Source
import scala.util.Try
// discussion: https://groups.google.com/forum/#!topic/play-framework-dev/t2g-TWbqtzY
startWhen {
case _: ReservationConfirmed => New
} andThen {
case New => {
case ReservationConfirmed(reservationId, customerId, totalAmount) =>
WaitingForPayment {
@pawelkaczor
pawelkaczor / getreservation.sh
Created August 1, 2016 07:20
Get reservation
http :9110/ecommerce/sales/reservation/r1
@pawelkaczor
pawelkaczor / ReservationProjection.scala
Created August 1, 2016 07:19
Reservation Projection
class ReservationProjection(dao: ReservationDao)(implicit ec: ExecutionContext) extends Projection {
override def consume(eventMsg: OfficeEventMessage): ProjectionAction[Write] = {
eventMsg.event match {
case ReservationCreated(id, clientId) =>
val newView = ReservationView(id, clientId, Opened, new Date(now().getMillis))
dao.createOrUpdate(newView)
case ReservationConfirmed(id, clientId, _) =>
@pawelkaczor
pawelkaczor / CreateReservation.sh
Created August 1, 2016 07:16
Create Reservation - httpie
http :9100/ecommerce/sales Command-Type:ecommerce.sales.CreateReservation reservationId="r1" customerId="customer-1"
@pawelkaczor
pawelkaczor / SalesServiceRoute.scala
Created August 1, 2016 07:15
Sales Service [write-front] - route
def route =
pathPrefix("ecommerce") {
path("sales") {
handle[ecommerce.sales.Command]
}
}
@pawelkaczor
pawelkaczor / HTTPCommandHandler.scala
Created August 1, 2016 07:13
HTTP Command Handler
def handle[A <: Command](implicit f: Formats): Route
@pawelkaczor
pawelkaczor / ReservationOfficeCreation.scala
Created August 1, 2016 07:09
Creation of Reservation Office
OfficeFactory.office[Reservation]
@pawelkaczor
pawelkaczor / RemoteOfficeId.scala
Last active August 1, 2016 07:06
RemoteOfficeId.scala
RemoteOfficeId(
id = "Reservation",
department = "Sales",
messageClass = classOf[sales.Command]
)