Skip to content

Commit

Permalink
chore: cleanup comment on iterateAll
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWhitehead committed Dec 22, 2022
1 parent 6dd8717 commit 892ec4e
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1495,12 +1495,12 @@ public Page<Blob> getNextPage() {
public Iterable<Blob> iterateAll() {
// drop to our interface type to help type inference below with the stream.
Page<Blob> curr = this;
// iterateAll on AbstractPage isn't very friendly to decoration, as getNextPage isn't actually
// ever called. This means we aren't able to apply our retry wrapping there.
// Instead, what we do is create a stream which will attempt to call getNextPage repeatedly
// until we meet some condition of exhaustion. At that point we can apply our retry logic.
Predicate<Page<Blob>> exhausted = p -> p != null && p.hasNextPage();
// Create a stream which will attempt to call getNextPage repeatedly until we meet our
// condition of exhaustion. By doing this we are able to rely on the retry logic in
// getNextPage
return () ->
streamIterate(curr, p -> p != null && p.hasNextPage(), Page::getNextPage)
streamIterate(curr, exhausted, Page::getNextPage)
.filter(Objects::nonNull)
.flatMap(p -> StreamSupport.stream(p.getValues().spliterator(), false))
.iterator();
Expand Down

0 comments on commit 892ec4e

Please sign in to comment.