Short lightning talk about the HBase plugin for Akka Persistence and how it's how key design was specifically tuned for increasing numeric sequential idenfitiers, so that the cluster can be utilised properly.
https://github.com/ktoso/akka-persistence-hbase
6. Compared to “Good ol’ CRUD Model”
state
“Mutable Record”
state
=
apply(es)
“Series of Events”
7. super quick domain modelling!
sealed trait Command!
case class GiveMe(geeCoins: Int) extends Command!
case class TakeMy(geeCoins: Int) extends Command
Commands - what others “tell” us; not persisted
case class Wallet(geeCoins: Int) {!
def updated(diff: Int) = State(geeCoins + diff)!
}
State - reflection of a series of events
sealed trait Event!
case class BalanceChangedBy(geeCoins: Int) extends Event!
Events - reflect effects, past tense; persisted
8. var state = S0
!
persistenceId = “a”
!
PersistentActor
Command
!
!
Journal
24. Eventsourced, recovery
/** MUST NOT SIDE-EFFECT! */!
def receiveRecover = {!
case replayedEvent: Event => !
state = updateState(replayedEvent)!
}
re-using updateState, as seen in
receiveCommand
Akka
Persistence
ScalaDays
72. Optimising recovery
001-a-0001,
001-a-0051
id = “a”
002-a-0002,
002-a-00052
003-a-0003,
003-a-0053
049-a-0049,
049-a-0099…
for short recovery = no need
to check all servers!
replay!
(to seqNr = 2)