Skip to content

Instantly share code, notes, and snippets.

@ignasi35
Created February 21, 2020 08:49
Show Gist options
  • Save ignasi35/9d64c13ab969b21f7ad0eb2f5157a3c0 to your computer and use it in GitHub Desktop.
Save ignasi35/9d64c13ab969b21f7ad0eb2f5157a3c0 to your computer and use it in GitHub Desktop.
Manually managed Lagom readside
class HelloreadSide extends ReadSideProcessor[HelloWorldEvent] {
override def aggregateTags: Set[AggregateEventTag[HelloWorldEvent]] =
Set(HelloWorldEvent.Tag.tag)
override def buildHandler()
: ReadSideProcessor.ReadSideHandler[HelloWorldEvent] = {
new ReadSideHandler[HelloWorldEvent] {
override def globalPrepare(): Future[Done] = Future.successful(Done)
// Returns the last Offset processed by this readside processor.
override def prepare(
tag: AggregateEventTag[HelloWorldEvent]
): Future[Offset] = ???
// processes the event and updates the offset
override def handle()
: Flow[EventStreamElement[HelloWorldEvent], Done, NotUsed] = {
Flow[EventStreamElement[HelloWorldEvent]]
.mapAsync(1) { eventElement =>
???
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment