Skip to content

Commit

Permalink
Fix pagination for events by persistence id
Browse files Browse the repository at this point in the history
Always query the event between the last known sequence number and the
upper limit, instead of the sequence number in a page range after the
last known number. Using the `limit` parameter to the query makes it
possible to retrieve batches of the desired size.

The previous method ignored higher number if the lower sequence numbers
were missing, and considered the source done so far.

Fix safety-data#11
  • Loading branch information
satabin committed Aug 22, 2017
1 parent 897f316 commit 72ff291
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.15
sbt.version=0.13.16
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private class EventsByPersistenceIdSource(conf: Config, redis: RedisClient, pers
if (buffer.isEmpty) {
// so, we need to fill this buffer
state = Querying
redis.zrangebyscore[Array[Byte]](journalKey(persistenceId), Limit(currentSequenceNr), Limit(math.min(currentSequenceNr + max - 1, to))).onComplete {
redis.zrangebyscore[Array[Byte]](journalKey(persistenceId), Limit(currentSequenceNr), Limit(to), Some(0l -> max)).onComplete {
case Success(events) =>
callback.invoke(events.map(persistentFromBytes(_)))
case Failure(t) =>
Expand Down

0 comments on commit 72ff291

Please sign in to comment.