Skip to content

Instantly share code, notes, and snippets.

@jsanda
Created July 15, 2015 13:27
Show Gist options
  • Save jsanda/7f500b6932de3b9c636f to your computer and use it in GitHub Desktop.
Save jsanda/7f500b6932de3b9c636f to your computer and use it in GitHub Desktop.
Observable<Lease> leases = queryLeases(timeSlice)
.flatMap(Observable::from)
.map(row -> new Lease(timeSlice.getTime(), row.getInt(1), row.getString(2), row.getBool(3)))
.filter(lease -> !lease.isFinished())
.toList()
.repeat()
.takeUntil(List::isEmpty)
.flatMap(Observable::from);
// At this point I want to fetch the tasks for the lease,
// execute each task, then delete the tasks partition,
// and reschedule the tasks for subsequent execution
leases.subscribe(
System.out::println,
Throwable::printStackTrace,
() -> System.out.println("done!")
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment