Skip to content

Commit

Permalink
sandbox-on-x: Support beginAfter in state updates. (#9624)
Browse files Browse the repository at this point in the history
* sandbox-on-x: Support `beginAfter` in state updates.

CHANGELOG_BEGIN
CHANGELOG_END

* sandbox-on-x: Update a TODO comment.
  • Loading branch information
SamirTalwar authored May 10, 2021
1 parent 26a8011 commit 6c919b3
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,19 @@ case class ReadWriteServiceBridge(
var stateUpdatesWasCalledAlready = false
override def stateUpdates(beginAfter: Option[Offset]): Source[(Offset, Update), NotUsed] = {
// TODO for PoC purposes:
// no beginAfter supported
// neither multiple subscriptions
// neither bootstrapping the bridge from indexer persistence
assert(
beginAfter.isEmpty,
"Re-subscribing not supported. Only supported to subscribe once, and from inception.",
)
// This method may only be called once, either with `beginAfter` set or unset.
// A second call will result in an error unless the server is restarted.
// Bootstrapping the bridge from indexer persistence is supported.
synchronized {
if (stateUpdatesWasCalledAlready)
throw new IllegalStateException("not allowed to call this twice")
else stateUpdatesWasCalledAlready = true
}
logger.info("Indexer subscribed to state updates.")
queueSource
beginAfter match {
case None => queueSource
case Some(offset) => queueSource.dropWhile(_._1 <= offset)
}
}

val (queue: BoundedSourceQueue[Submission], queueSource: Source[(Offset, Update), NotUsed]) =
Expand Down

0 comments on commit 6c919b3

Please sign in to comment.