36.
PersistentActorの復元
Persistent
Actor
Journal
persistenceId = “c100”
count = 3
CountIncreased
① ②
CountIncreased
CountIncreased
Select Events where
persistenceId = “c100”
③
48.
イベントにタグを付与する
class ThreadEventAdapter extends WriteEventAdapter {
override def manifest(event: Any): String = ""
val tags = Set("Thread")
override def toJournal(event: Any): Any = event match {
case e: ThreadEvent =>
Tagged(event, tags)
case _ =>
event
}
}
49.
Projection
• Read Model Projection / Read Model Updaterともいう
• ドメインイベントを元に、Viewを構築する
50.
Projection
val readJournal = PersistenceQuery(system)
.readJournalFor[LeveldbReadJournal](LeveldbReadJournal.Identifier)
implicit val mat = ActorMaterializer()(system)
val dao = new ThreadsDao(dbConfig)
val projection = new ThreadProjection(dao)
readJournal
.eventsByTag("Thread", projection.lastOffset)
.mapAsync(1) { envelope =>
projection.update(envelope.event).map(_ => envelope.offset)
}
.mapAsync(1) { offset => projection.saveProgress(offset) }
.runWith(Sink.ignore)
Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.
Be the first to comment