Skip to content

Instantly share code, notes, and snippets.

@pawelkaczor
Created August 1, 2016 07:19
Show Gist options
  • Save pawelkaczor/4e958a218a0097a5b52c5040d55b3d75 to your computer and use it in GitHub Desktop.
Save pawelkaczor/4e958a218a0097a5b52c5040d55b3d75 to your computer and use it in GitHub Desktop.
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, _) =>
dao.updateStatus(id, Confirmed)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment