Skip to content

Instantly share code, notes, and snippets.

@ghostbuster91
Last active May 7, 2020 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghostbuster91/b0789e8394ef2961c21c44d4a105f235 to your computer and use it in GitHub Desktop.
Save ghostbuster91/b0789e8394ef2961c21c44d4a105f235 to your computer and use it in GitHub Desktop.
Observable
.intervalWithFixedDelay(config.interval)
.mapEval( _ => repository.findAllWaitingOrderedBySerialIdAsc(config.maxBatchSize))
.distinctUntilChanged
.scan(List.empty[Withdrawal]) { (oldSet, newSet) =>
newSet.takeWhile(w => !oldSet.contains(w))
}
.flatMap(Observable.fromIterable)
.bufferTimedAndCounted(config.timeWindow, config.batchSizeThreshold)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment