I was looking into WorkState.scala for the below example:
https://developer.lightbend.com/guides/akka-distributed-workers-scala/
If I keep running the demo indefinitely, the acceptedWorkIds and doneWorkIds will keep growing as they are Set[String].
Besides recovery will take longer as no snapshot enabled. Now, say If I don’t need records older than 24 hours and set TTL for 24 hours for persistent journal, then problem would be, if for a particular completed Work, WorkAccepted(work) event records expires but rest stays, in that case if I just add
if(isAccepted(workId))
check for all update events, will that will be sufficient ?
case WorkStarted(workId) =>
if(isAccepted(workId)) {
val (work, rest) = pendingWork.dequeue
require(workId == work.workId, s"WorkStarted expected workId $workId == ${work.workId}")
copy(
pendingWork = rest,
workInProgress = workInProgress + (workId -> work))
} else this